Class SetExpressions


  • public final class SetExpressions
    extends Object
    Defines helper methods for the set expressions
    Since:
    2.0
    • Method Detail

      • allElementsTrue

        public static Expression allElementsTrue​(Expression first,
                                                 Expression... additional)
        Returns true if no element of a set evaluates to false, otherwise, returns false. Accepts a single argument expression.
        Parameters:
        first - an expression to evaluate
        additional - any additional expressions
        Returns:
        the new expression
        MongoDB documentation
        Aggregration Expression: $allElementsTrue
      • anyElementTrue

        public static Expression anyElementTrue​(Expression first,
                                                Expression... additional)
        Returns true if any elements of a set evaluate to true; otherwise, returns false. Accepts a single argument expression.
        Parameters:
        first - an expression to evaluate
        additional - any additional expressions
        Returns:
        the new expression
        MongoDB documentation
        Aggregration Expression: $anyElementTrue
      • setDifference

        public static Expression setDifference​(Expression first,
                                               Expression second)
        Returns a set with elements that appear in the first set but not in the second set; i.e. performs a relative complement of the second set relative to the first. Accepts exactly two argument expressions.
        Parameters:
        first - the first array expression
        second - the second expression
        Returns:
        the new expression
        MongoDB documentation
        Aggregration Expression: $setDifference
      • setEquals

        public static Expression setEquals​(Expression first,
                                           Expression... additional)
        Returns true if the input sets have the same distinct elements. Accepts two or more argument expressions.
        Parameters:
        first - the first array expression
        additional - additional expressions
        Returns:
        the new expression
        MongoDB documentation
        Aggregration Expression: $setEquals
      • setIntersection

        public static Expression setIntersection​(Expression first,
                                                 Expression... additional)
        Returns a set with elements that appear in all of the input sets. Accepts any number of argument expressions.
        Parameters:
        first - the first array expression
        additional - additional expressions
        Returns:
        the new expression
        MongoDB documentation
        Aggregration Expression: $setIntersection
      • setIsSubset

        public static Expression setIsSubset​(Expression first,
                                             Expression second)
        Returns true if all elements of the first set appear in the second set, including when the first set equals the second set; i.e. not a strict subset. Accepts exactly two argument expressions.
        Parameters:
        first - the first array expression
        second - the second expression
        Returns:
        the new expression
        MongoDB documentation
        Aggregration Expression: $setIsSubset
      • setUnion

        public static Expression setUnion​(Expression first,
                                          Expression... additional)
        Returns a set with elements that appear in any of the input sets.
        Parameters:
        first - the first array expression
        additional - additional expressions
        Returns:
        the new expression
        MongoDB documentation
        Aggregration Expression: $setUnion