Class ConstructorCall

  • All Implemented Interfaces:
    Operation

    public final class ConstructorCall
    extends CallableOperation
    ConstructorCall is an Operation that represents a call to a constructor, and holds a reference to a reflective Constructor object.

    As an Operation, a call to constructor c with n arguments is represented as c : [t1,...,tn] → c, where the output type c is also the name of the class.

    • Field Detail

      • constructor

        private final Constructor<?> constructor
      • hashCodeCached

        private int hashCodeCached
      • hashCodeComputed

        private boolean hashCodeComputed
    • Constructor Detail

      • ConstructorCall

        public ConstructorCall​(Constructor<?> constructor)
        Creates object corresponding to the given reflection constructor.
        Parameters:
        constructor - reflective object for a constructor
    • Method Detail

      • getConstructor

        public Constructor<?> getConstructor()
        Return the reflective constructor corresponding to this ConstructorCall.
        Returns:
        Constructor object called by this constructor call
      • toString

        public String toString()
        Returns concise string representation of this ConstructorCall.
        Overrides:
        toString in class Object
      • getName

        public String getName()
        Description copied from interface: Operation
        Returns the name for the operation.
        Returns:
        the name for this operation
      • equals

        public boolean equals​(Object o)
        Tests whether the parameter is a call to the same constructor.
        Overrides:
        equals in class Object
        Parameters:
        o - an object
        Returns:
        true if o is a ConstructorCall referring to same constructor object; false otherwise
      • hashCode

        public int hashCode()
        Returns the hashCode for the constructor called by this object.
        Overrides:
        hashCode in class Object
      • execute

        public ExecutionOutcome execute​(Object[] statementInput)
        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.

        Performs call to the constructor given the objects as actual parameters, and the output stream for any output.

        Specified by:
        execute in class CallableOperation
        Parameters:
        statementInput - is an array of values corresponding to signature of the constructor
        Returns:
        results of executing this statement
        See Also:
        TypedOperation.execute(Object[])
      • toParsableString

        public 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).

        Generates a string representation of the constructor signature.

        Examples:

        
         java.util.ArrayList.<init>()
         java.util.ArrayList.<init>(java.util.Collection)
         
        Specified by:
        toParsableString in class CallableOperation
        Parameters:
        declaringType - the declaring type for this operation
        inputTypes - the input types for this operation
        outputType - the output type for this operation
        Returns:
        signature string for constructor
        See Also:
        parse(String)