Package org.synchronoss.cpo.core
Class BindableCpoWhere
java.lang.Object
org.synchronoss.cpo.core.Node
org.synchronoss.cpo.core.BindableCpoWhere
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Node>,CpoWhere
Default
CpoWhere implementation: a bindable where-clause node that is also a Node, allowing leaf comparisons to be chained into branches via addWhere(CpoWhere) and
rendered to native SQL/CQL text via toString(CpoClass).- Author:
- david berry
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty where clause with no comparison, attribute, or value set.BindableCpoWhere(Logical logical, String attr, Comparison comp, T value) Creates a leaf where clause comparing the named attribute to a literal value, joined to a subsequent clause (if any) by the given logical operator.BindableCpoWhere(Logical logical, String attr, Comparison comp, T value, boolean not) Creates a leaf where clause comparing the named attribute to a literal value, optionally negated, joined to a subsequent clause (if any) by the given logical operator. -
Method Summary
Modifier and TypeMethodDescriptionvoidChains another where clause onto this one, joined by this instance'sLogicaloperator, turning this instance into a branch node.Gets the name of the bean attribute on the left-hand side of the comparison.Gets the native datastore function applied to the left-hand attribute before comparison.Gets theComparisonoperator used to compare the attribute against the value or right-hand attribute.Gets theLogicaloperator used to join this where clause with the next one added viaCpoWhere.addWhere(CpoWhere).getName()Gets a string representing the name of this instance of the CpoOrderBybooleangetNot()Gets whether this where clause's comparison result is negated.Gets the name of the bean attribute to compare against, when comparing two attributes rather than an attribute and a literal value.Gets the native datastore function applied to the right-hand attribute before comparison.Gets the literal, unescaped value used in place of a bound comparison value.getValue()Gets the literal value the attribute is compared against.Gets the native datastore function applied to the comparison value before comparison.voidSets the name of the bean attribute on the left-hand side of the comparison.voidSets a native datastore function (e.g.voidsetComparison(Comparison comparison) Sets theComparisonoperator (e.g. equals, greater-than) used to compare the attribute against the value or right-hand attribute.voidsetLogical(Logical logical) Sets theLogicaloperator (e.g.voidSets a string representing the name of this instance of the CpoOrderByvoidsetNot(boolean b) Sets whether this where clause's comparison result should be negated.voidSets the name of the bean attribute to compare against, when comparing two attributes rather than an attribute and a literal value.voidSets a native datastore function (e.g.voidsetStaticValue(String staticValue) Sets a literal, unescaped value to use in place of a bound comparison value, inserted directly into the native expression.voidSets the literal value to compare the attribute against.voidSets a native datastore function (e.g.Builds the native (SQL/CQL) fragment for this where clause against the given class's attribute-to-column mapping.Methods inherited from class org.synchronoss.cpo.core.Node
acceptDFVisitor, addChild, addChildSort, addChildSort, clone, compareTo, createNode, equals, getAllowChildren, getChildCount, getChildList, getFirstChild, getNextSibling, getParentNode, getPrevSibling, hashCode, hasParent, insertParentAfter, insertParentBefore, insertSiblingAfter, insertSiblingBefore, isLeaf, release, removeAll, removeChild, removeChildNode, setFirstChild, setNextSibling, setParent, setPrevSibling
-
Constructor Details
-
BindableCpoWhere
Creates a leaf where clause comparing the named attribute to a literal value, joined to a subsequent clause (if any) by the given logical operator.- Type Parameters:
T- the type of the comparison value- Parameters:
logical- the logical operator joining this clause to the next one addedattr- the name of the bean attribute to comparecomp- the comparison operator to applyvalue- the value to compare the attribute against
-
BindableCpoWhere
Creates a leaf where clause comparing the named attribute to a literal value, optionally negated, joined to a subsequent clause (if any) by the given logical operator.- Type Parameters:
T- the type of the comparison value- Parameters:
logical- the logical operator joining this clause to the next one addedattr- the name of the bean attribute to comparecomp- the comparison operator to applyvalue- the value to compare the attribute againstnot-trueto negate the comparison,falseotherwise
-
BindableCpoWhere
public BindableCpoWhere()Creates an empty where clause with no comparison, attribute, or value set.
-
-
Method Details
-
setComparison
Sets theComparisonoperator (e.g. equals, greater-than) used to compare the attribute against the value or right-hand attribute.- Specified by:
setComparisonin interfaceCpoWhere- Parameters:
comparison- the comparison operator for this where clause
-
getComparison
Gets theComparisonoperator used to compare the attribute against the value or right-hand attribute.- Specified by:
getComparisonin interfaceCpoWhere- Returns:
- the comparison operator for this where clause
-
setLogical
Sets theLogicaloperator (e.g. AND, OR) used to join this where clause with the next one added viaCpoWhere.addWhere(CpoWhere).- Specified by:
setLogicalin interfaceCpoWhere- Parameters:
logical- the logical operator joining this clause to the next
-
getLogical
Gets theLogicaloperator used to join this where clause with the next one added viaCpoWhere.addWhere(CpoWhere).- Specified by:
getLogicalin interfaceCpoWhere- Returns:
- the logical operator joining this clause to the next
-
setAttribute
Sets the name of the bean attribute on the left-hand side of the comparison.- Specified by:
setAttributein interfaceCpoWhere- Parameters:
s- the attribute name
-
getAttribute
Gets the name of the bean attribute on the left-hand side of the comparison.- Specified by:
getAttributein interfaceCpoWhere- Returns:
- the attribute name
-
setRightAttribute
Sets the name of the bean attribute to compare against, when comparing two attributes rather than an attribute and a literal value.- Specified by:
setRightAttributein interfaceCpoWhere- Parameters:
s- the right-hand attribute name
-
getRightAttribute
Gets the name of the bean attribute to compare against, when comparing two attributes rather than an attribute and a literal value.- Specified by:
getRightAttributein interfaceCpoWhere- Returns:
- the right-hand attribute name
-
setValue
Sets the literal value to compare the attribute against. -
getValue
Gets the literal value the attribute is compared against. -
setStaticValue
Sets a literal, unescaped value to use in place of a bound comparison value, inserted directly into the native expression.- Specified by:
setStaticValuein interfaceCpoWhere- Parameters:
staticValue- the static (literal) value text
-
getStaticValue
Gets the literal, unescaped value used in place of a bound comparison value.- Specified by:
getStaticValuein interfaceCpoWhere- Returns:
- the static (literal) value text
-
getNot
public boolean getNot()Gets whether this where clause's comparison result is negated. -
setNot
public void setNot(boolean b) Sets whether this where clause's comparison result should be negated. -
toString
Builds the native (SQL/CQL) fragment for this where clause against the given class's attribute-to-column mapping. UnlikeObject.toString(), this resolves attribute names to datastore column names and does not require the class to declare the attribute (unresolved names are used verbatim, e.g. as raw column names).- Parameters:
cpoClass- the class metadata used to resolve attributes to datastore columns- Returns:
- the native expression fragment for this clause
-
addWhere
Chains another where clause onto this one, joined by this instance'sLogicaloperator, turning this instance into a branch node.The added clause must itself be a
Node(all built-inCpoWhereimplementations are); it is attached as a child node of this instance.- Specified by:
addWherein interfaceCpoWhere- Parameters:
cw- the where clause to add- Throws:
CpoException- if the where clause cannot be added
-
setAttributeFunction
Sets a native datastore function (e.g. `UPPER`) to apply to the left-hand attribute before comparison.- Specified by:
setAttributeFunctionin interfaceCpoWhere- Parameters:
s- the function expression to apply to the attribute
-
getAttributeFunction
Gets the native datastore function applied to the left-hand attribute before comparison.- Specified by:
getAttributeFunctionin interfaceCpoWhere- Returns:
- the function expression applied to the attribute
-
setValueFunction
Sets a native datastore function (e.g. `UPPER`) to apply to the comparison value before comparison.- Specified by:
setValueFunctionin interfaceCpoWhere- Parameters:
s- the function expression to apply to the value
-
getValueFunction
Gets the native datastore function applied to the comparison value before comparison.- Specified by:
getValueFunctionin interfaceCpoWhere- Returns:
- the function expression applied to the value
-
setRightAttributeFunction
Sets a native datastore function (e.g. `UPPER`) to apply to the right-hand attribute before comparison.- Specified by:
setRightAttributeFunctionin interfaceCpoWhere- Parameters:
s- the function expression to apply to the right-hand attribute
-
getRightAttributeFunction
Gets the native datastore function applied to the right-hand attribute before comparison.- Specified by:
getRightAttributeFunctionin interfaceCpoWhere- Returns:
- the function expression applied to the right-hand attribute
-
getName
Gets a string representing the name of this instance of the CpoOrderBy -
setName
Sets a string representing the name of this instance of the CpoOrderBy
-