Class CallableOperation

java.lang.Object
randoop.operation.CallableOperation
All Implemented Interfaces:
Operation
Direct Known Subclasses:
ArrayCreation, ArrayElementSet, ConstructorCall, EnumConstant, FieldGet, FieldSet, InitializedArrayCreation, MethodCall, NonreceiverTerm, ReflectionArrayCreation, UncheckedCast

public abstract class CallableOperation extends Object implements Operation
CallableOperation is an abstract implementation of the Operation interface to provide default implementations of Operation predicates that are false except for a few kinds of operations.
  • Constructor Details

    • CallableOperation

      public CallableOperation()
  • Method Details

    • isStatic

      public boolean isStatic()
      Description copied from interface: Operation
      Predicate to indicate whether object represents a static operation on the declaring class.
      Specified by:
      isStatic in interface Operation
      Returns:
      true if operation corresponds to static method or field of a class, and false otherwise
    • isMessage

      public boolean isMessage()
      Description copied from interface: Operation
      Predicate to indicate whether object represents a method-call-like operation (either static or instance). This includes field getters and setters, which are operations that access fields.
      Specified by:
      isMessage in interface Operation
      Returns:
      true if operation is method-like, and false otherwise
    • isMethodCall

      public boolean isMethodCall()
      Description copied from interface: Operation
      Indicates whether this object represents a method-call operation (either static or instance). This excludes getters and setters.
      Specified by:
      isMethodCall in interface Operation
      Returns:
      true if this operation is a method call, and false otherwise
    • isConstructorCall

      public boolean isConstructorCall()
      Description copied from interface: Operation
      Predicate to indicate whether object represents a call to a constructor.
      Specified by:
      isConstructorCall in interface Operation
      Returns:
      true if operation is a constructor call, and false otherwise
    • isConstantField

      public boolean isConstantField()
      Description copied from interface: Operation
      Predicate to indicate whether this object represents a constant field.
      Specified by:
      isConstantField in interface Operation
      Returns:
      true if this operation is a constant field, and false otherwise
    • isNonreceivingValue

      public boolean isNonreceivingValue()
      Description copied from interface: Operation
      Predicate to indicate whether this object represents a value of a non-receiving type (includes numbers, strings, and null).
      Specified by:
      isNonreceivingValue in interface Operation
      Returns:
      true if object is a non-receiving value, and false otherwise
    • isUncheckedCast

      public boolean isUncheckedCast()
      Description copied from interface: Operation
      Predicate to indicate whether this object represents an unchecked cast.
      Specified by:
      isUncheckedCast in interface Operation
      Returns:
      true if the this object is a cast, and false otherwise
    • getValue

      public Object getValue()
      Description copied from interface: Operation
      Returns the "value" of an operation that is actually a ground term, meaning a constant of some form. Only null if value is null, otherwise throws an exception if there is not a reasonable meaning of value for type of operation.

      This is a hack to allow randoop.main.GenBranchDir to do mutation.

      Specified by:
      getValue in interface Operation
      Returns:
      object reference to value
    • satisfies

      public boolean satisfies(ReflectionPredicate reflectionPredicate)
      Checks whether reflective object contained in an Operation satisfies the predicate. Since there is no reflective object in an CallableOperation, returns false.
      Specified by:
      satisfies in interface Operation
      Parameters:
      reflectionPredicate - ReflectionPredicate against which object to be checked
      Returns:
      false as there is no object to check
    • execute

      public abstract ExecutionOutcome execute(Object[] input)
      Performs this operation using the array of input values. Returns the results of execution as an ResultOrException object and can output results to specified PrintStream.
      Parameters:
      input - array containing appropriate inputs to operation
      Returns:
      results of executing this statement
    • appendCode

      public abstract void appendCode(Type declaringType, TypeTuple inputTypes, Type outputType, List<Variable> inputVars, StringBuilder b)
      Produces a Java source code representation of this statement and appends it to the given StringBuilder.
      Parameters:
      declaringType - the declaring type for this operation
      inputTypes - the input types for this operation
      outputType - the output type for this operation
      inputVars - the list of variables that are inputs to operation
      b - the StringBuilder to which code is added
    • getArgumentString

      String getArgumentString(Variable variable)
      Returns the variable as a string to be used as an argument to an operation. Determines if the value of the variable can be given in short form. In the short output format, statements that assign to a primitive or string literal, like "int x = 3" are not added to a sequence; instead, the value (e.g. "3") is inserted directly added as arguments to method calls.
      Parameters:
      variable - the variable for which the argument string is constructed
      Returns:
      the argument string for the variable
    • toParsableString

      public abstract String toParsableString(Type declaringType, TypeTuple inputTypes, Type outputType)
      Returns a string representation of this Operation, which can be read by static parse method for class. For a class C implementing the Operation interface, this method should return a String s such that parsing the string returns an object equivalent to this object, i.e. C.parse(this.s).equals(this).
      Parameters:
      declaringType - the declaring type for this operation
      inputTypes - the input types for this operation
      outputType - the output type for this operation
      Returns:
      a string representation of this operation
    • getReflectionObject

      public AccessibleObject getReflectionObject()