Class BindableCpoWhere

java.lang.Object
org.synchronoss.cpo.core.Node
org.synchronoss.cpo.core.BindableCpoWhere
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Node>, CpoWhere
Direct Known Subclasses:
JdbcCpoWhere

public class BindableCpoWhere extends Node implements 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 Details

    • BindableCpoWhere

      public 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.
      Type Parameters:
      T - the type of the comparison value
      Parameters:
      logical - the logical operator joining this clause to the next one added
      attr - the name of the bean attribute to compare
      comp - the comparison operator to apply
      value - the value to compare the attribute against
    • BindableCpoWhere

      public 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.
      Type Parameters:
      T - the type of the comparison value
      Parameters:
      logical - the logical operator joining this clause to the next one added
      attr - the name of the bean attribute to compare
      comp - the comparison operator to apply
      value - the value to compare the attribute against
      not - true to negate the comparison, false otherwise
    • BindableCpoWhere

      public BindableCpoWhere()
      Creates an empty where clause with no comparison, attribute, or value set.
  • Method Details

    • setComparison

      public void setComparison(Comparison comparison)
      Sets the Comparison operator (e.g. equals, greater-than) used to compare the attribute against the value or right-hand attribute.
      Specified by:
      setComparison in interface CpoWhere
      Parameters:
      comparison - the comparison operator for this where clause
    • getComparison

      public Comparison getComparison()
      Gets the Comparison operator used to compare the attribute against the value or right-hand attribute.
      Specified by:
      getComparison in interface CpoWhere
      Returns:
      the comparison operator for this where clause
    • setLogical

      public void setLogical(Logical logical)
      Sets the Logical operator (e.g. AND, OR) used to join this where clause with the next one added via CpoWhere.addWhere(CpoWhere).
      Specified by:
      setLogical in interface CpoWhere
      Parameters:
      logical - the logical operator joining this clause to the next
    • getLogical

      public Logical getLogical()
      Gets the Logical operator used to join this where clause with the next one added via CpoWhere.addWhere(CpoWhere).
      Specified by:
      getLogical in interface CpoWhere
      Returns:
      the logical operator joining this clause to the next
    • setAttribute

      public void setAttribute(String s)
      Sets the name of the bean attribute on the left-hand side of the comparison.
      Specified by:
      setAttribute in interface CpoWhere
      Parameters:
      s - the attribute name
    • getAttribute

      public String getAttribute()
      Gets the name of the bean attribute on the left-hand side of the comparison.
      Specified by:
      getAttribute in interface CpoWhere
      Returns:
      the attribute name
    • setRightAttribute

      public void setRightAttribute(String s)
      Sets the name of the bean attribute to compare against, when comparing two attributes rather than an attribute and a literal value.
      Specified by:
      setRightAttribute in interface CpoWhere
      Parameters:
      s - the right-hand attribute name
    • getRightAttribute

      public String 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:
      getRightAttribute in interface CpoWhere
      Returns:
      the right-hand attribute name
    • setValue

      public void setValue(Object s)
      Sets the literal value to compare the attribute against.
      Specified by:
      setValue in interface CpoWhere
      Parameters:
      s - the comparison value
    • getValue

      public Object getValue()
      Gets the literal value the attribute is compared against.
      Specified by:
      getValue in interface CpoWhere
      Returns:
      the comparison value
    • setStaticValue

      public void setStaticValue(String staticValue)
      Sets a literal, unescaped value to use in place of a bound comparison value, inserted directly into the native expression.
      Specified by:
      setStaticValue in interface CpoWhere
      Parameters:
      staticValue - the static (literal) value text
    • getStaticValue

      public String getStaticValue()
      Gets the literal, unescaped value used in place of a bound comparison value.
      Specified by:
      getStaticValue in interface CpoWhere
      Returns:
      the static (literal) value text
    • getNot

      public boolean getNot()
      Gets whether this where clause's comparison result is negated.
      Specified by:
      getNot in interface CpoWhere
      Returns:
      `true` if the comparison is negated (NOT), `false` otherwise
    • setNot

      public void setNot(boolean b)
      Sets whether this where clause's comparison result should be negated.
      Specified by:
      setNot in interface CpoWhere
      Parameters:
      b - `true` to negate the comparison (NOT), `false` otherwise
    • toString

      public String toString(CpoClass cpoClass)
      Builds the native (SQL/CQL) fragment for this where clause against the given class's attribute-to-column mapping. Unlike Object.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

      public void addWhere(CpoWhere cw) throws CpoException
      Chains another where clause onto this one, joined by this instance's Logical operator, turning this instance into a branch node.

      The added clause must itself be a Node (all built-in CpoWhere implementations are); it is attached as a child node of this instance.

      Specified by:
      addWhere in interface CpoWhere
      Parameters:
      cw - the where clause to add
      Throws:
      CpoException - if the where clause cannot be added
    • setAttributeFunction

      public void setAttributeFunction(String s)
      Sets a native datastore function (e.g. `UPPER`) to apply to the left-hand attribute before comparison.
      Specified by:
      setAttributeFunction in interface CpoWhere
      Parameters:
      s - the function expression to apply to the attribute
    • getAttributeFunction

      public String getAttributeFunction()
      Gets the native datastore function applied to the left-hand attribute before comparison.
      Specified by:
      getAttributeFunction in interface CpoWhere
      Returns:
      the function expression applied to the attribute
    • setValueFunction

      public void setValueFunction(String s)
      Sets a native datastore function (e.g. `UPPER`) to apply to the comparison value before comparison.
      Specified by:
      setValueFunction in interface CpoWhere
      Parameters:
      s - the function expression to apply to the value
    • getValueFunction

      public String getValueFunction()
      Gets the native datastore function applied to the comparison value before comparison.
      Specified by:
      getValueFunction in interface CpoWhere
      Returns:
      the function expression applied to the value
    • setRightAttributeFunction

      public void setRightAttributeFunction(String s)
      Sets a native datastore function (e.g. `UPPER`) to apply to the right-hand attribute before comparison.
      Specified by:
      setRightAttributeFunction in interface CpoWhere
      Parameters:
      s - the function expression to apply to the right-hand attribute
    • getRightAttributeFunction

      public String getRightAttributeFunction()
      Gets the native datastore function applied to the right-hand attribute before comparison.
      Specified by:
      getRightAttributeFunction in interface CpoWhere
      Returns:
      the function expression applied to the right-hand attribute
    • getName

      public String getName()
      Gets a string representing the name of this instance of the CpoOrderBy
      Specified by:
      getName in interface CpoWhere
      Returns:
      String The name of the CpoOrderBy
    • setName

      public void setName(String name)
      Sets a string representing the name of this instance of the CpoOrderBy
      Specified by:
      setName in interface CpoWhere
      Parameters:
      name - The name of the CpoOrderBy