Class Expression

java.lang.Object
com.couchbase.lite.Expression
Direct Known Subclasses:
MetaExpression, PredictionFunction, PropertyExpression, VariableExpression

public abstract class Expression extends Object
The expression used in constructing a query.
  • Constructor Details

    • Expression

      public Expression()
  • Method Details

    • value

      @NonNull public static Expression value(@Nullable Object value)
      Create value expression with given value
      Parameters:
      value - the value
      Returns:
      the value expression
    • string

      @NonNull public static Expression string(@Nullable String value)
      Create value expression with given String value
      Parameters:
      value - the String value
      Returns:
      the value expression
    • number

      @NonNull public static Expression number(@Nullable Number value)
      Create value expression with given Number value
      Parameters:
      value - the Number value
      Returns:
      the value expression
    • intValue

      @NonNull public static Expression intValue(int value)
      Create value expression with given integer value
      Parameters:
      value - the integer value
      Returns:
      the value expression
    • longValue

      @NonNull public static Expression longValue(long value)
      Create value expression with given long value
      Parameters:
      value - the long value
      Returns:
      the value expression
    • floatValue

      @NonNull public static Expression floatValue(float value)
      Create value expression with given float value
      Parameters:
      value - the float value
      Returns:
      the value expression
    • doubleValue

      @NonNull public static Expression doubleValue(double value)
      Create value expression with given double value
      Parameters:
      value - the double value
      Returns:
      the value expression
    • booleanValue

      @NonNull public static Expression booleanValue(boolean value)
      Create value expression with given boolean value
      Parameters:
      value - the boolean value
      Returns:
      the value expression
    • date

      @NonNull public static Expression date(@Nullable Date value)
      Create value expression with given Date value
      Parameters:
      value - the Date value
      Returns:
      the value expression
    • map

      @NonNull public static Expression map(@Nullable Map<String,Object> value)
      Creates value expression with the given map.
      Parameters:
      value - the map value
      Returns:
      the value expression.
    • list

      @NonNull public static Expression list(@Nullable List<Object> value)
      Create value expression with the given list.
      Parameters:
      value - the list value.
      Returns:
      the value expression.
    • all

      @NonNull public static PropertyExpression all()
      Creates a * expression to express all properties
      Returns:
      a property expression.
    • property

      @NonNull public static PropertyExpression property(@NonNull String property)
      Create a property expression representing the value of the given property.
      Parameters:
      property - the name of the property in the form of a key path.
      Returns:
      a property expression.
    • parameter

      @NonNull public static Expression parameter(@NonNull String name)
      Creates a parameter expression with the given parameter name.
      Parameters:
      name - The parameter name
      Returns:
      A parameter expression.
    • negated

      @NonNull public static Expression negated(@NonNull Expression expression)
      Create a negated expression to represent the negated result of the given expression.
      Parameters:
      expression - the expression to be negated.
      Returns:
      a negated expression.
    • not

      @NonNull public static Expression not(@NonNull Expression expression)
      Create a negated expression to represent the negated result of the given expression.
      Parameters:
      expression - the expression to be negated.
      Returns:
      a negated expression.
    • fullTextIndex

      @NonNull public static FullTextIndexExpression fullTextIndex(@NonNull String indexName)
      Create a full-text index expression referencing a full-text index with the given index name.

      When there is a need to specify the data source in which the index has been created (e.g. in multi-collection join statement, calls the from(_ alias: String) method from the returned FullTextIndexExpressionProtocol object to specify the data source.

      Parameters:
      indexName - The name of the full-text index.
      Returns:
      The full-text index expression referring to a full text index in the specified data source.
    • toString

      @NonNull public String toString()
      Overrides:
      toString in class Object
    • multiply

      @NonNull public Expression multiply(@NonNull Expression expression)
      Create a multiply expression to multiply the current expression by the given expression.
      Parameters:
      expression - the expression to multiply by.
      Returns:
      a multiply expression.
    • divide

      @NonNull public Expression divide(@NonNull Expression expression)
      Create a divide expression to divide the current expression by the given expression.
      Parameters:
      expression - the expression to divide by.
      Returns:
      a divide expression.
    • modulo

      @NonNull public Expression modulo(@NonNull Expression expression)
      Create a modulo expression to modulo the current expression by the given expression.
      Parameters:
      expression - the expression to modulo by.
      Returns:
      a modulo expression.
    • add

      @NonNull public Expression add(@NonNull Expression expression)
      Create an add expression to add the given expression to the current expression
      Parameters:
      expression - an expression to add to the current expression.
      Returns:
      an add expression.
    • subtract

      @NonNull public Expression subtract(@NonNull Expression expression)
      Create a subtract expression to subtract the given expression from the current expression.
      Parameters:
      expression - an expression to subtract from the current expression.
      Returns:
      a subtract expression.
    • lessThan

      @NonNull public Expression lessThan(@NonNull Expression expression)
      Create a less than expression that evaluates whether or not the current expression is less than the given expression.
      Parameters:
      expression - the expression to compare with the current expression.
      Returns:
      a less than expression.
    • lessThanOrEqualTo

      @NonNull public Expression lessThanOrEqualTo(@NonNull Expression expression)
      Create a less than or equal to expression that evaluates whether or not the current expression is less than or equal to the given expression.
      Parameters:
      expression - the expression to compare with the current expression.
      Returns:
      a less than or equal to expression.
    • greaterThan

      @NonNull public Expression greaterThan(@NonNull Expression expression)
      Create a greater than expression that evaluates whether or not the current expression is greater than the given expression.
      Parameters:
      expression - the expression to compare with the current expression.
      Returns:
      a greater than expression.
    • greaterThanOrEqualTo

      @NonNull public Expression greaterThanOrEqualTo(@NonNull Expression expression)
      Create a greater than or equal to expression that evaluates whether or not the current expression is greater than or equal to the given expression.
      Parameters:
      expression - the expression to compare with the current expression.
      Returns:
      a greater than or equal to expression.
    • equalTo

      @NonNull public Expression equalTo(@NonNull Expression expression)
      Create an equal to expression that evaluates whether or not the current expression is equal to the given expression.
      Parameters:
      expression - the expression to compare with the current expression.
      Returns:
      an equal to expression.
    • notEqualTo

      @NonNull public Expression notEqualTo(@NonNull Expression expression)
      Create a NOT equal to expression that evaluates whether or not the current expression is not equal to the given expression.
      Parameters:
      expression - the expression to compare with the current expression.
      Returns:
      a NOT equal to expression.
    • and

      @NonNull public Expression and(@NonNull Expression expression)
      Create a logical AND expression that performs logical AND operation with the current expression.
      Parameters:
      expression - the expression to AND with the current expression.
      Returns:
      a logical AND expression.
    • or

      @NonNull public Expression or(@NonNull Expression expression)
      Create a logical OR expression that performs logical OR operation with the current expression.
      Parameters:
      expression - the expression to OR with the current expression.
      Returns:
      a logical OR expression.
    • like

      @NonNull public Expression like(@NonNull Expression expression)
      Create a Like expression that evaluates whether or not the current expression is LIKE the given expression.
      Parameters:
      expression - the expression to compare with the current expression.
      Returns:
      a Like expression.
    • regex

      @NonNull public Expression regex(@NonNull Expression expression)
      Create a regex match expression that evaluates whether or not the current expression regex matches the given expression.
      Parameters:
      expression - the expression to compare with the current expression.
      Returns:
      a regex match expression.
    • is

      @NonNull public Expression is(@NonNull Expression expression)
      Create an IS expression that evaluates whether or not the current expression is equal to the given expression.
      Parameters:
      expression - the expression to compare with the current expression.
      Returns:
      an IS expression.
    • isNot

      @NonNull public Expression isNot(@NonNull Expression expression)
      Create an IS NOT expression that evaluates whether or not the current expression is not equal to the given expression.
      Parameters:
      expression - the expression to compare with the current expression.
      Returns:
      an IS NOT expression.
    • between

      @NonNull public Expression between(@NonNull Expression expression1, @NonNull Expression expression2)
      Create a between expression that evaluates whether or not the current expression is between the given expressions inclusively.
      Parameters:
      expression1 - the inclusive lower bound expression.
      expression2 - the inclusive upper bound expression.
      Returns:
      a between expression.
    • collate

      @NonNull public Expression collate(@NonNull Collation collation)
      Creates a Collate expression with the given Collation specification. Commonly the collate expression is used in the Order BY clause or the string comparison  expression (e.g. equalTo or lessThan) to specify how the two strings are compared.
      Parameters:
      collation - The collation object.
      Returns:
      A Collate expression.
    • in

      @NonNull public Expression in(@NonNull Expression... expressions)
      Create an IN expression that evaluates whether or not the current expression is in the given expressions.
      Parameters:
      expressions - the expression array to evaluate with.
      Returns:
      an IN expression.
    • isValued

      @NonNull public Expression isValued()
      Creates an IS VALUED expression that returns true if the current expression is valued.
      Returns:
      An IS VALUED expression.
    • isNotValued

      @NonNull public Expression isNotValued()
      Creates an IS NOT VALUED expression that returns true if the current expression is NOT VALUED.
      Returns:
      An IS NOT VALUED expression.
    • isNullOrMissing

      @Deprecated @NonNull public Expression isNullOrMissing()
      Deprecated.
      Use Expression.isNotValued
      Creates an IS NULL OR MISSING expression that evaluates whether or not the current expression is null or missing.
      Returns:
      An IS NULL expression.
    • notNullOrMissing

      @Deprecated @NonNull public Expression notNullOrMissing()
      Deprecated.
      Use Expression.isValued
      Creates an NOT IS NULL OR MISSING expression that evaluates whether or not the current expression is NOT null or missing.
      Returns:
      An NOT IS NULL expression.