Class Expressions

    • Constructor Detail

      • Expressions

        public Expressions()
    • Method Detail

      • or

        public Expressions or​(Expression expression)
        Create a new $or expression on the root, then adds to it the current expressions attached at the root and the expression passes as parameter.

        Example: Suppose we have the following expression as json:

         {"firstName": "ali"} 

        Then we added the following:

          expressions.or(Expression.and(
                  Expression.of("lastName", Operator.$eq, "ibrahim"),
                  Expression.of("age", Operator.$gte, 10)
          ));
         
        Then the output could be represented as:
         {
             "$or": [
                  {"firstName": "ali"},
                  {
                      "$and": [
                          {"lastName": "ibrahim"},
                          {"age": {"$gte": 10}},
                      ]
                  }
             ]
         }
         
        Or in sql as:
          where firstName = "ali" or lastName = "ibrahim" and age >= 10
         
      • and

        public Expressions and​(Expression expression)
        Add the parameter expression to the list of expression in the expressions object.

        Example: Suppose we have the following expression as json:

         {"firstName": "ali"} 

        Then we added the following:

          expressions.and(Expression.of("birthDate", Operator.$gt, "1980-10-10"));
          expressions.and(Expression.or(
              Expression.of("lastName", Operator.$eq, "ibrahim"),
              Expression.of("age", Operator.$in, 10, 30)
          ));
        
         
        Then the output could be represented as:
         {
             "firstName": "ali",
             "birthDate": {"$gt": "1980-10-10"},
             "$or": [
                  {"lastName": "ibrahim"},
                  {"age": {"$in": [10, 30]}}
             ]
         }
         
        Or in sql as:
         where firstName = "ali" and birthDate > "1980-10-10"
             and (lastName = "ibrahim" or age in (10, 30) )