/testability-explorer/src/main/java/com/google/test/metric/method/op/turing/FieldAssignment.java

http://testability-explorer.googlecode.com/ · Java · 57 lines · 33 code · 9 blank · 15 comment · 0 complexity · ba5cfbfc81d8b898657169cfa137de93 MD5 · raw file

  1. /*
  2. * Copyright 2007 Google Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.google.test.metric.method.op.turing;
  17. import com.google.test.metric.FieldInfo;
  18. import com.google.test.metric.TestabilityVisitor;
  19. import com.google.test.metric.Variable;
  20. public class FieldAssignment extends Operation {
  21. private final Variable fieldInstance;
  22. private final FieldInfo field;
  23. private final Variable value;
  24. public FieldAssignment(int lineNumber, Variable fieldInstance,
  25. FieldInfo field, Variable value) {
  26. super(lineNumber);
  27. this.fieldInstance = fieldInstance;
  28. this.field = field;
  29. this.value = value;
  30. }
  31. public Variable getFieldInstance() {
  32. return fieldInstance;
  33. }
  34. public FieldInfo getField() {
  35. return field;
  36. }
  37. public Variable getValue() {
  38. return value;
  39. }
  40. @Override
  41. public void visit(TestabilityVisitor.Frame visitor) {
  42. visitor.assignField(fieldInstance, field, value, getLineNumber());
  43. }
  44. @Override
  45. public String toString() {
  46. return field + " <- " + value;
  47. }
  48. }