public class UpdateItemStateObject extends AbstractStateObject
new_value
specified for an update operation must be compatible in type with the
field to which it is assigned.
update_item ::= [identification_variable.]{state_field | single_valued_association_field} = new_value
UpdateItem
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NEW_VALUE_PROPERTY
Notifies the new value property has changed.
|
Constructor and Description |
---|
UpdateItemStateObject(UpdateClauseStateObject parent)
Creates a new
UpdateItemStateObject . |
UpdateItemStateObject(UpdateClauseStateObject parent,
java.lang.String path,
StateObject newValue)
Creates a new
UpdateItemStateObject . |
UpdateItemStateObject(UpdateClauseStateObject parent,
java.lang.String path,
java.lang.String newValue)
Creates a new
UpdateItemStateObject . |
Modifier and Type | Method and Description |
---|---|
void |
accept(StateObjectVisitor visitor)
Visits this
StateObject by the given visitor . |
protected void |
addChildren(java.util.List<StateObject> children)
Adds the children of this
StateObject to the given list. |
void |
appendToPath(java.lang.String text)
Appends the given sequence of characters to the path expression.
|
INewValueStateObjectBuilder |
getBuilder()
Creates and returns a new
INewValueStateObjectBuilder that can be used to
programmatically create a new value expression and once the expression is complete,
INewValueStateObjectBuilder.commit() will push the StateObject
representation of that expression as this new value object. |
UpdateItem |
getExpression()
Returns the actual parsed object if this
StateObject representation of the JPQL query
was created by parsing an existing JPQL query. |
StateObject |
getNewValue()
Returns the
StateObject representing the new value. |
UpdateClauseStateObject |
getParent()
Returns the parent of this
StateObject . |
java.lang.String |
getPath()
Returns the string representation of the path expression.
|
StateFieldPathExpressionStateObject |
getStateFieldPath()
Returns
|
boolean |
hasNewValue()
Determines whether the
StateObject representing the new value is present. |
protected void |
initialize()
Initializes this state object.
|
boolean |
isEquivalent(StateObject stateObject)
Determines whether the given
StateObject is equivalent to this one, i.e. the
information of both StateObject is the same. |
ListIterable<java.lang.String> |
items()
Returns the segments in the state field path in order.
|
int |
itemsSize()
Returns the number of segments in the path expression.
|
void |
parseNewValue(java.lang.String newValue)
Parses the given JPQL fragment, which represents the new value.
|
void |
setExpression(UpdateItem 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 . |
void |
setNewValue(StateObject newValue)
Sets the new value to be the given
StateObject . |
void |
setPath(java.lang.String path)
Changes the path expression with the list of segments, the identification variable will also
be updated with the first segment.
|
void |
setPaths(java.util.ListIterator<java.lang.String> paths)
Changes the path expression with the list of segments, the identification variable will also
be updated with the first segment.
|
void |
setPaths(java.lang.String[] paths)
Changes the path expression with the list of segments, the identification variable will also
be updated with the first segment.
|
void |
setVirtualIdentificationVariable(java.lang.String identificationVariable)
The state field path expression is not qualified by the identification variable.
|
protected void |
toTextInternal(java.lang.Appendable writer)
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. |
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
public static final java.lang.String NEW_VALUE_PROPERTY
public UpdateItemStateObject(UpdateClauseStateObject parent)
UpdateItemStateObject
.parent
- The parent of this state object, which cannot be null
java.lang.NullPointerException
- The given parent cannot be null
public UpdateItemStateObject(UpdateClauseStateObject parent, java.lang.String path, StateObject newValue)
UpdateItemStateObject
.parent
- The parent of this state object, which cannot be null
path
- The state field path to receive the new valuenewValue
- The actual expression representing the new valuejava.lang.NullPointerException
- The given parent cannot be null
public UpdateItemStateObject(UpdateClauseStateObject parent, java.lang.String path, java.lang.String newValue)
UpdateItemStateObject
.parent
- The parent of this state object, which cannot be null
path
- The state field path to receive the new valuenewValue
- The JPQL fragment representing the new valuejava.lang.NullPointerException
- The given parent cannot be null
public void accept(StateObjectVisitor visitor)
StateObject
by the given visitor
.visitor
- The visitor
to visit this objectprotected void addChildren(java.util.List<StateObject> children)
StateObject
to the given list.addChildren
in class AbstractStateObject
children
- The list used to store the childrenpublic void appendToPath(java.lang.String text)
text
- The sequence of characters to append to the path expressionpublic INewValueStateObjectBuilder getBuilder()
INewValueStateObjectBuilder
that can be used to
programmatically create a new value expression and once the expression is complete,
INewValueStateObjectBuilder.commit()
will push the StateObject
representation of that expression as this new value object.public UpdateItem getExpression()
StateObject
representation of the JPQL query
was created by parsing an existing JPQL query.getExpression
in interface StateObject
getExpression
in class AbstractStateObject
StateObject
or null
when the JPQL query is manually created (i.e. not from a string)public StateObject getNewValue()
StateObject
representing the new value.null
if it's not yet definedpublic UpdateClauseStateObject getParent()
StateObject
.getParent
in interface StateObject
getParent
in class AbstractStateObject
StateObject
, which is null
only when
this is the root of the hierarchypublic java.lang.String getPath()
null
public StateFieldPathExpressionStateObject getStateFieldPath()
public boolean hasNewValue()
StateObject
representing the new value is present.true
the new value exists; otherwise false
protected void initialize()
initialize
in class AbstractStateObject
public boolean isEquivalent(StateObject stateObject)
StateObject
is equivalent to this one, i.e. the
information of both StateObject
is the same.isEquivalent
in interface StateObject
isEquivalent
in class AbstractStateObject
stateObject
- The StateObject
to compare its content to this onetrue
if both object are equivalent; false
otherwisepublic ListIterable<java.lang.String> items()
ListIterable
over the paths of the state field pathpublic int itemsSize()
public void parseNewValue(java.lang.String newValue)
newValue
- The string representation of the new value to parse and to convert into a
StateObject
public void setExpression(UpdateItem expression)
parsed object
object, which should only be done
when this object is instantiated during the conversion of a parsed JPQL query into StateObjects
.expression
- The parsed object
representing an update itempublic void setNewValue(StateObject newValue)
StateObject
.newValue
- The StateObject
representing the new valuepublic void setPath(java.lang.String path)
path
- The new path expressionpublic void setPaths(java.util.ListIterator<java.lang.String> paths)
paths
- The new path expressionpublic void setPaths(java.lang.String[] paths)
paths
- The new path expressionpublic void setVirtualIdentificationVariable(java.lang.String identificationVariable)
identificationVariable
- The virtual variable that was generated based on the entity nameprotected void toTextInternal(java.lang.Appendable writer) throws java.io.IOException
StateObject
, which should not be used to
define a true
string representation of a JPQL query but should be used for
debugging purposes.toTextInternal
in class AbstractStateObject
writer
- The writer used to print out the string representationjava.io.IOException
- This should never happens, it is only required because Appendable
is used instead of any concrete class