Class Variable

java.lang.Object
randoop.sequence.Variable
All Implemented Interfaces:
Comparable<Variable>
Direct Known Subclasses:
DummyVariable

public class Variable extends Object implements Comparable<Variable>
Represents the result of a statement call in a sequence.
  • Field Details

    • index

      public final int index
    • sequence

      public final Sequence sequence
  • Constructor Details

    • Variable

      public Variable(Sequence owner, int i)
    • Variable

      protected Variable()
      Do not use! Only for use by DummyVariable.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getType

      public Type getType()
      Returns the type of this variable.
      Returns:
      the type of this variable
    • getDeclaringStatement

      public Statement getDeclaringStatement()
      The statement that produced this variable.
      Returns:
      the statement to which this variable belongs
    • getDeclIndex

      public int getDeclIndex()
      The index of the statement that creates this value.
      Returns:
      the statement index where this variable is created
    • getName

      public String getName()
      Returns the name of this variable.
      Returns:
      the name of this variable as a string
    • getName

      private String getName(String className, int i)
      The name of this variable using the given type name and index.
      Parameters:
      className - the classname to use
      i - the index to use in the name
      Returns:
      the variable name that appends the index to the classname
    • compareTo

      public int compareTo(Variable o)
      Specified by:
      compareTo in interface Comparable<Variable>
    • classToVariableName

      static String classToVariableName(Type type)
      Build a variable name from the name of the given type.
      Parameters:
      type - the type
      Returns:
      the variable name as a string
    • classNameToVariableName

      private static String classNameToVariableName(String className)
      Convert the classname to a variable name, preserving camel case if used.
      Parameters:
      className - the class name
      Returns:
      the variable form of the classname
    • shouldInlineLiterals

      public boolean shouldInlineLiterals()
      True if this variable's value should be inlined as a literal at call sites, rather than referencing the variable.
      Returns:
      whether this variable's value should be inlined as a literal at call sites