Class Expressions


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

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static dev.morphia.aggregation.expressions.impls.DocumentExpression document()
      Creates a new DocumentExpression.
      static dev.morphia.aggregation.expressions.impls.DocumentExpression document​(String name, dev.morphia.aggregation.expressions.impls.Expression expression)
      Creates a new DocumentExpression.
      static dev.morphia.aggregation.expressions.impls.Expression field​(String name)
      Creates a field expression for the given value.
      static dev.morphia.aggregation.expressions.impls.Expression literal​(Object value)
      Returns a value without parsing.
      static dev.morphia.aggregation.expressions.impls.Expression meta()
      Returns the metadata associated with a document in a pipeline operations, e.g.
      static dev.morphia.aggregation.expressions.impls.DocumentExpression of()
      Deprecated, for removal: This API element is subject to removal in a future version.
      static <T> List<T> toList​(T first, T... additional)  
      static dev.morphia.aggregation.expressions.impls.ValueExpression value​(Object value)
      Returns a value without parsing.
    • Method Detail

      • document

        public static dev.morphia.aggregation.expressions.impls.DocumentExpression document()
        Creates a new DocumentExpression.
        Returns:
        the new expression
        Since:
        2.3
      • document

        public static dev.morphia.aggregation.expressions.impls.DocumentExpression document​(String name,
                                                                                            dev.morphia.aggregation.expressions.impls.Expression expression)
        Creates a new DocumentExpression.
        Parameters:
        name - the first field name
        expression - the first field value
        Returns:
        the new expression
        Since:
        2.3
      • field

        public static dev.morphia.aggregation.expressions.impls.Expression field​(String name)
        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
      • literal

        public static dev.morphia.aggregation.expressions.impls.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 dev.morphia.aggregation.expressions.impls.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
      • of

        @Deprecated(forRemoval=true,
                    since="2.3")
        public static dev.morphia.aggregation.expressions.impls.DocumentExpression of()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Creates a new DocumentExpression.
        Returns:
        the new expression
      • toList

        @MorphiaInternal
        public static <T> List<T> toList​(T first,
                                         T... additional)
        Type Parameters:
        T - the element type
        Parameters:
        first - the first item
        additional - additional items
        Returns:
        a list of them all
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • value

        public static dev.morphia.aggregation.expressions.impls.ValueExpression value​(@Nullable
                                                                                      Object value)
        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