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 Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DocumentExpressiondocument()Creates a new DocumentExpression.static DocumentExpressiondocument(String name, Expression expression)Creates a new DocumentExpression.static Expressionfield(String name)Creates a field expression for the given value.static Expressionliteral(Object value)Returns a value without parsing.static Expressionmeta()Returns the metadata associated with a document in a pipeline operations, e.g.static DocumentExpressionof()Deprecated, for removal: This API element is subject to removal in a future version.static <T> List<T>toList(T first, T... additional)static ValueExpressionvalue(Object value)Returns a value without parsing.
-
-
-
Method Detail
-
document
public static DocumentExpression document()
Creates a new DocumentExpression.- Returns:
- the new expression
- Since:
- 2.3
-
document
public static DocumentExpression document(String name, Expression expression)
Creates a new DocumentExpression.- Parameters:
name- the first field nameexpression- the first field value- Returns:
- the new expression
- Since:
- 2.3
-
field
public static 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 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
-
of
@Deprecated(forRemoval=true, since="2.3") public static 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 itemadditional- 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 ValueExpression value(@Nullable Object value)
Returns a value without parsing. Note that this is different fromliteral(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
-
-