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

http://testability-explorer.googlecode.com/ · Java · 79 lines · 48 code · 13 blank · 18 comment · 1 complexity · 4e56359b9020d1666551e5cea34932a3 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.TestabilityVisitor;
  18. import com.google.test.metric.Variable;
  19. import java.util.List;
  20. public class MethodInvocation extends Operation {
  21. private final String name;
  22. private final String clazzName;
  23. private final Variable methodThis;
  24. private final List<Variable> parameters;
  25. private final Variable returnVariable;
  26. public MethodInvocation(int lineNumber, String clazz, String name,
  27. Variable methodThis, List<Variable> parameters,
  28. Variable returnVariable) {
  29. super(lineNumber);
  30. this.clazzName = clazz;
  31. this.name = name;
  32. this.methodThis = methodThis;
  33. this.parameters = parameters;
  34. this.returnVariable = returnVariable;
  35. }
  36. public List<Variable> getParameters() {
  37. return parameters;
  38. }
  39. public String getName() {
  40. return name;
  41. }
  42. public String getOwner() {
  43. return clazzName;
  44. }
  45. @Override
  46. public String toString() {
  47. return clazzName + ":" + name;
  48. }
  49. @Override
  50. public void visit(TestabilityVisitor.Frame visitor) {
  51. visitor.recordMethodCall(clazzName, getLineNumber(), name,
  52. methodThis, parameters, returnVariable);
  53. }
  54. public Variable getMethodThis() {
  55. return methodThis;
  56. }
  57. /**
  58. * @return true iff this is an invocation of methodName in a class className
  59. */
  60. public boolean equals(String className, String methodName) {
  61. return className.equals(clazzName) && methodName.equals(name);
  62. }
  63. public String getClazzName() {
  64. return clazzName;
  65. }
  66. }