Class Expressions

java.lang.Object
dev.morphia.aggregation.expressions.Expressions

public final class Expressions extends Object
Defines helper methods for various expressions.
Since:
2.0
  • Method Details

    • document

      public static DocumentExpression document()
      Creates a new DocumentExpression.
      Returns:
      the new expression
      Since:
      2.3
    • document

      public static DocumentExpression document(String name, Object expression)
      Creates a new DocumentExpression.
      Parameters:
      name - the first field name
      expression - the first field value
      Returns:
      the new expression
      Since:
      2.3
    • field

      @Deprecated(since="3.0", forRemoval=true) public static Expression field(String name)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a field expression for the given value. If the value does not already start with '$', it will be prepended automatically.
      Parameters:
      name - the field name
      Returns:
      the new expression
    • filter

      public static FilterExpression filter(Object input, Object cond)
      Parameters:
      input - An expression that resolves to an array.
      cond - An expression that resolves to a boolean value used to determine if an element should be included in the output array. The expression references each element of the input array individually with the variable name specified in as.
      Returns:
      MongoDB documentation
      Aggregration Expression: $filter
    • literal

      public static Expression literal(Object value)
      Returns a value without parsing. Use for values that the aggregation pipeline may interpret as an expression.
      Parameters:
      value - the value
      Returns:
      the new expression
      MongoDB documentation
      Aggregration Expression: $literal
    • meta

      public static Expression meta()
      Returns the metadata associated with a document in a pipeline operations, e.g. "textScore" when performing text search.
      Returns:
      the new expression
      MongoDB documentation
      Aggregration Expression: $meta
    • meta

      public static dev.morphia.aggregation.expressions.impls.MetaExpression meta(MetadataKeyword metadataKeyword)
      Returns the metadata associated with a document in a pipeline operations, e.g. "textScore" when performing text search.
      Parameters:
      metadataKeyword - the keyword to use
      Returns:
      the new expression
      Since:
      3.0
      Since server release
      4.4
      MongoDB documentation
      Aggregration Expression: $meta
    • value

      @Deprecated(since="3.0", forRemoval=true) public static dev.morphia.aggregation.expressions.impls.ValueExpression value(@Nullable Object value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns a value without parsing. Note that this is different from literal(Object) in that the given value will dropped directly in to the pipeline for use/evaluation in whatever context the value is used.
      Parameters:
      value - the value
      Returns:
      the new expression