Class IdentificationVariableStateObject

All Implemented Interfaces:
StateObject

public class IdentificationVariableStateObject extends SimpleStateObject
This state object represents a single identification variable, which is identifying TODO.
Since:
2.4
Version:
2.4
See Also:
  • Field Details

    • DEFINED_PROPERTY

      public static final String DEFINED_PROPERTY
      Notify a change in the defined property.
      See Also:
  • Constructor Details

    • IdentificationVariableStateObject

      public IdentificationVariableStateObject(StateObject parent)
      Creates a new IdentificationVariableStateObject.
      Parameters:
      parent - The parent of this state object, which cannot be null
      Throws:
      NullPointerException - The given parent cannot be null
    • IdentificationVariableStateObject

      public IdentificationVariableStateObject(StateObject parent, String variable)
      Creates a new IdentificationVariableStateObject.
      Parameters:
      parent - The parent of this state object, which cannot be null
      variable - The name of the identification variable
      Throws:
      NullPointerException - The given parent cannot be null
  • Method Details

    • accept

      public void accept(StateObjectVisitor visitor)
      Description copied from interface: StateObject
      Visits this StateObject by the given visitor.
      Parameters:
      visitor - The visitor to visit this object
    • addProblems

      protected void addProblems(List<Problem> problems)
      Description copied from class: AbstractStateObject
      Adds to the given list the problems that were found with the current state of this StateObject, which means there are validation issues.
      Overrides:
      addProblems in class AbstractStateObject
      Parameters:
      problems - The list to which the problems are added
    • checkIntegrity

      protected void checkIntegrity(String text)
      Makes sure the current identification variable and the given one are the same. If they are not, then clears the cached values related to the type.
      Parameters:
      text - The new identification variable
    • clearResolvedObjects

      protected void clearResolvedObjects()
      Clears the values related to the managed type and type.
    • getExpression

      public IdentificationVariable getExpression()
      Description copied from interface: StateObject
      Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
      Specified by:
      getExpression in interface StateObject
      Overrides:
      getExpression in class AbstractStateObject
      Returns:
      The parsed object when a JPQL query is parsed and converted into a StateObject or null when the JPQL query is manually created (i.e. not from a string)
    • getManagedType

      public IManagedType getManagedType()
      Returns the IManagedType associated with the field handled by this object. If this object does not handle a field that has a IManagedType, then null should be returned.

      For example: "SELECT e FROM Employee e", the object for e would be returning the IManagedType for Employee.

      Returns:
      Either the IManagedType, if it could be resolved; null otherwise
    • getMapping

      public IMapping getMapping()
      Returns
    • getType

      public IType getType()
      Returns the IType of the field handled by this object.
      Returns:
      Either the IType that was resolved by this state object or the IType for IType.UNRESOLVABLE_TYPE if it could not be resolved
    • getTypeDeclaration

      public ITypeDeclaration getTypeDeclaration()
      Returns the ITypeDeclaration of the field handled by this object.
      Returns:
      Either the ITypeDeclaration that was resolved by this object or the ITypeDeclaration for IType.UNRESOLVABLE_TYPE if it could not be resolved
    • isEquivalent

      public boolean isEquivalent(StateObject stateObject)
      Description copied from interface: StateObject
      Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
      Specified by:
      isEquivalent in interface StateObject
      Overrides:
      isEquivalent in class SimpleStateObject
      Parameters:
      stateObject - The StateObject to compare its content to this one
      Returns:
      true if both object are equivalent; false otherwise
    • isVirtual

      public boolean isVirtual()
      Determines whether this identification variable is virtual, meaning it's not part of the query but is required for proper navigability.
      Returns:
      true if this identification variable was virtually created to fully qualify path expression; false if it was parsed
    • resolveManagedType

      protected IManagedType resolveManagedType()
      Retrieves the IManagedType that is mapped to the identification variable, if and only if the identification variable is used to declare an entity.
      Returns:
      Either the IManagedType declared by the identification variable or null if it could not be resolved
    • resolveMapping

      protected IMapping resolveMapping()
      Resolves
    • resolveType

      protected IType resolveType()
      Resolves the IType of the property handled by this object.
      Returns:
      Either the IType that was resolved by this object or the IType for IType.UNRESOLVABLE_TYPE if it could not be resolved
    • resolveTypeDeclaration

      protected ITypeDeclaration resolveTypeDeclaration()
      Resolves the ITypeDeclaration of the property handled by this object.
      Returns:
      Either the ITypeDeclaration that was resolved by this object or the ITypeDeclaration for IType.UNRESOLVABLE_TYPE if it could not be resolved
    • setExpression

      public void setExpression(IdentificationVariable expression)
      Keeps a reference of the parsed object object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query into StateObjects.
      Parameters:
      expression - The parsed object representing an identification variable
    • setText

      public void setText(String text)
      Description copied from class: SimpleStateObject
      Sets the text held by this state object.
      Overrides:
      setText in class SimpleStateObject
      Parameters:
      text - This model's text value
    • setVirtual

      public void setVirtual(boolean virtual)
      Sets whether this identification variable is virtual, meaning it's not part of the query but is required for proper navigability.
      Parameters:
      virtual - true if this identification variable was virtually created to fully qualify path expression; false if it was parsed
    • toTextInternal

      protected void toTextInternal(Appendable writer) throws IOException
      Description copied from class: AbstractStateObject
      Prints out a string representation of this StateObject, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.
      Overrides:
      toTextInternal in class SimpleStateObject
      Parameters:
      writer - The writer used to print out the string representation
      Throws:
      IOException - This should never happens, it is only required because Appendable is used instead of any concrete class