Interface CQL


  • public interface CQL
    • Method Detail

      • copy

        static Predicate copy​(CqnPredicate pred)
        Creates a copy of the given predicate.
        Parameters:
        pred - the predicate to be copied
        Returns:
        the copy
      • copy

        static Predicate copy​(CqnPredicate pred,
                              Modifier modifier)
        Creates a modified copy of the given predicate.
        Parameters:
        pred - the predicate to be copied
        modifier - the modifier for altering the copy
        Returns:
        the modified copy
      • copy

        static <S extends CqnStatement> S copy​(S statement)
        Creates a copy of the given CQN statement.
        Type Parameters:
        S - the type of CqnStatement
        Parameters:
        statement - the CQN statement to be copied
        Returns:
        the copy
      • copy

        static <S extends CqnStatement> S copy​(S statement,
                                               Modifier modifier)
        Creates a modified copy of the given CQN statement.
        Type Parameters:
        S - the type of CqnStatement
        Parameters:
        statement - the CQN statement to be copied
        modifier - the modifier for altering the copy
        Returns:
        the modified copy
      • func

        static <T> FunctionCall<T> func​(String name,
                                        CqnValue... args)
        Creates a CDS QL function call that is send to the underlying data store.
        Type Parameters:
        T - the return type of the function call
        Parameters:
        name - the name of the function to be called
        args - the arguments of the function
        Returns:
        the CDS QL function call
      • func

        static <T> FunctionCall<T> func​(String name,
                                        List<? extends CqnValue> args)
        Creates a CDS QL function call that is send to the underlying data store.
        Type Parameters:
        T - the return type of the function call
        Parameters:
        name - the name of the function to be called
        args - the arguments of the function
        Returns:
        the CDS QL function call
      • booleanFunc

        static BooleanFunction booleanFunc​(String name,
                                           List<? extends CqnValue> args)
        Creates a CDS QL function call that is send to the underlying data store.
        Parameters:
        name - the name of the function to be called
        args - the arguments of the function
        Returns:
        the CDS QL function call
      • literal

        @Deprecated
        static <T> Literal<T> literal​(T value)
        Deprecated.
        use constant() for _constant_ and val() for _non-constant_ handling
        Creates a CDS QL Literal to be used in queries.
        Type Parameters:
        T - the type of the literal
        Parameters:
        value - the value of the literal
        Returns:
        the literal
      • constant

        static <T> Literal<T> constant​(T value)
        Creates a _constant_ CDS QL Literal hinting to the runtime that the value should be treated as constant.
        Type Parameters:
        T - the type of the constant
        Parameters:
        value - the value of the constant
        Returns:
        the literal
      • val

        static <T> Literal<T> val​(T value)
        Creates a _non-constant_ CDS QL Literal hinting to the runtime that the value should not be treated as constant.
        Type Parameters:
        T - the type of the non-constant value
        Parameters:
        value - the value of the non-constant value
        Returns:
        the literal
        See Also:
        param()
      • not

        static Predicate not​(CqnPredicate predicate)
        Negates a given CqnPredicate.
        Parameters:
        predicate - the CqnPredicate to be negated
        Returns:
        the negated predicate
      • and

        static Predicate and​(CqnPredicate p1,
                             CqnPredicate p2)
        Creates a conjunction of two given predicates
        Parameters:
        p1 - 1st operand of the conjunction
        p2 - 2nd operand of the conjunction
        Returns:
        the conjunction
      • or

        static Predicate or​(CqnPredicate p1,
                            CqnPredicate p2)
        Creates a disjunction of two given predicates
        Parameters:
        p1 - 1st operand of the disjunction
        p2 - 2nd operand of the disjunction
        Returns:
        the disjunction
      • and

        static Predicate and​(Iterable<? extends CqnPredicate> predicates)
        Creates a conjunction of given predicates
        Parameters:
        predicates - the predicates to connect
        Returns:
        the conjunction
      • or

        static Predicate or​(Iterable<? extends CqnPredicate> predicates)
        Creates a disjunction of given predicates
        Parameters:
        predicates - the predicates to connect
        Returns:
        the disjunction
      • param

        @Deprecated
        static <T> Parameter<T> param()
        Deprecated.
        instead use named or indexed parameters
        Creates a positional Parameter to be used in queries.
        Type Parameters:
        T - the type of the parameter
        Returns:
        the parameter
      • param

        static <T> Parameter<T> param​(int index)
        Creates an indexed Parameter to be used in CQN statements. Can be used with positional parameter values.
        Type Parameters:
        T - the type of the parameter
        Parameters:
        index - the parameter index. If used with positional parameter values, start with 0 for the first parameter
        Returns:
        the parameter
      • param

        static <T> Parameter<T> param​(String name)
        Creates a named Parameter to be used in queries.
        Type Parameters:
        T - the type of the parameter
        Parameters:
        name - the parameter name
        Returns:
        the parameter
      • plain

        static Value<?> plain​(String value)
        Creates a CQN plain value, which is directly send to the underlying data store.
        Parameters:
        value - the value content
        Returns:
        the plain value
      • count

        static Value<Long> count()
        Creates a count all function call.
        Returns:
        the count value
      • count

        static Value<Long> count​(CqnElementRef element)
        Creates a count function call on the given element.
        Parameters:
        element - the ref to the element to be counted
        Returns:
        the count value
      • min

        static <T> Value<T> min​(CqnValue value)
        Creates a min function call on the given element or expression.
        Type Parameters:
        T - the type of the value
        Parameters:
        value - the ref to the element to be counted or an expression
        Returns:
        the minimum value
      • max

        static <T> Value<T> max​(CqnValue value)
        Creates a max function call on the given element or expression.
        Type Parameters:
        T - the type of the value
        Parameters:
        value - the ref to the element to be counted or an expression
        Returns:
        the maximum value
      • sum

        static Value<Number> sum​(CqnValue value)
        Creates a sum function call on the given element or expression.
        Parameters:
        value - the ref to the element to be counted or an expression
        Returns:
        the sum value
      • average

        static Value<Number> average​(CqnValue value)
        Creates an average function call on the given element or expression.
        Parameters:
        value - the ref to the element to be counted or an expression
        Returns:
        the average value
      • countDistinct

        static Value<Long> countDistinct​(CqnValue value)
        Creates an count distinct function call on the given element or expression.
        Parameters:
        value - the ref to the element to be counted or an expression
        Returns:
        the count of distinct values
      • contains

        static Predicate contains​(CqnValue value,
                                  CqnValue substring,
                                  boolean caseInsensitive)
        Creates a predicate that tests whether a string value contains a given substring
        Parameters:
        value - the string value
        substring - the substring to test for
        caseInsensitive - whether the test should be case insensitive
        Returns:
        the predicate for the containment test
      • startsWith

        static Predicate startsWith​(CqnValue value,
                                    CqnValue prefix,
                                    boolean caseInsensitive)
        Creates a predicate that tests whether a string value starts with a given prefix
        Parameters:
        value - the string value
        prefix - the prefix to test for
        caseInsensitive - whether the test should be case insensitive
        Returns:
        the predicate for the containment test
      • endsWith

        static Predicate endsWith​(CqnValue value,
                                  CqnValue suffix,
                                  boolean caseInsensitive)
        Creates a predicate that tests whether a string value ends with a given suffix
        Parameters:
        value - the string value
        suffix - the suffix to test for
        caseInsensitive - whether the test should be case insensitive
        Returns:
        the predicate for the containment test
      • containment

        static Predicate containment​(CqnContainmentTest.Position position,
                                     CqnValue value,
                                     CqnValue substring,
                                     boolean caseInsensitive)
        Creates a predicate that tests whether a string value contains a given substring at a given position CqnContainmentTest.Position
        Parameters:
        position - the position
        value - the string value
        substring - the substring to test for
        caseInsensitive - whether the test should be case insensitive
        Returns:
        the predicate for the containment test
      • toLower

        static Value<String> toLower​(Value<String> val)
        Creates a CDS QL expression for converting the given string value to lower case using the rules of the underlying data store.
        Parameters:
        val - the String value to be converted
        Returns:
        the CDS QL expression for lower case conversion
      • toLower

        static Value<String> toLower​(String val)
        Creates a CDS QL expression for converting the given string value to lower case using the rules of the underlying data store.
        Parameters:
        val - the String value to be converted
        Returns:
        the CDS QL expression for lower case conversion
      • toUpper

        static Value<String> toUpper​(Value<String> val)
        Creates a CDS QL expression for converting the given string value to upper case using the rules of the underlying data store.
        Parameters:
        val - the String value to be converted
        Returns:
        the CDS QL expression for upper case conversion
      • toUpper

        static Value<String> toUpper​(String val)
        Creates a CDS QL expression for converting the given string value to upper case using the rules of the underlying data store.
        Parameters:
        val - the String value to be converted
        Returns:
        the CDS QL expression for upper case conversion
      • entity

        static StructuredType<?> entity​(String qualifiedName)
        Creates a StructuredType representing a CDS entity.
        Parameters:
        qualifiedName - the qualified name of the CDS entity
        Returns:
        the StructuredType representing the CDS entity
      • to

        static StructuredType<?> to​(String path)
        Creates a StructuredType representing a path from a CDS entity to another entity.
        Parameters:
        path - a String of association element names separated by '.'
        Returns:
        the StructuredType representing the path to a CDS entity
      • to

        static StructuredType<?> to​(List<? extends CqnReference.Segment> segments)
        Creates a StructuredType representing a path from a CDS entity to another entity.
        Parameters:
        segments - the segments of the path
        Returns:
        the StructuredType representing the path to a CDS entity
      • get

        static <T> ElementRef<T> get​(String path)
        Creates an ElementRef representing a path from a CDS entity to an element of this or another entity.
        Type Parameters:
        T - the type of the element
        Parameters:
        path - a String of element names separated by '.', where all except the last segment represent association elements.
        Returns:
        the ElementRef representing the path to the CDS element
      • get

        static <T> ElementRef<T> get​(List<? extends CqnReference.Segment> segments)
        Creates an ElementRef representing a path from a CDS entity to an element of this or another entity.
        Type Parameters:
        T - the type of the element
        Parameters:
        segments - the segments of the path
        Returns:
        the ElementRef representing the path to the CDS element
      • refSegment

        static RefSegment refSegment​(String id)
        Creates a segment of a structured type or element reference.
        Parameters:
        id - the id of the segment
        Returns:
        the segment
      • refSegments

        static List<RefSegment> refSegments​(List<String> segmentIds)
        Creates a list of reference segments.
        Parameters:
        segmentIds - the ids of the segments
        Returns:
        the segments
      • expression

        static Value<Number> expression​(CqnValue left,
                                        CqnArithmeticExpression.Operator op,
                                        CqnValue right)
        Creates an arithmetic expression.
        Parameters:
        left - the left-hand side of the expression
        op - the operator
        right - the right-hand side of the expression
        Returns:
        the arithmetic expression
      • comparison

        static Predicate comparison​(CqnValue lhs,
                                    CqnComparisonPredicate.Operator op,
                                    CqnValue rhs)
        Creates a comparison predicate.
        Parameters:
        lhs - the left-hand side of the comparison
        op - the comparison operator
        rhs - the right-hand side of the comparison
        Returns:
        the comparison predicate
      • in

        static Predicate in​(CqnValue lhs,
                            Collection<? extends CqnValue> values)
        Creates an in predicate.
        Parameters:
        lhs - the value to be checked if it's contained in the collection
        values - the collection of values
        Returns:
        the in predicate
      • in

        static Predicate in​(CqnValue lhs,
                            CqnValue valueSet)
        Creates an in predicate.
        Parameters:
        lhs - the value to be checked if it's contained in the collection
        valueSet - the value describing a collection of values
        Returns:
        the in predicate
      • search

        static Predicate search​(String term)
        Creates a search predicate.
        Parameters:
        term - the search term
        Returns:
        the search predicate
      • exists

        static Predicate exists​(CqnSelect subQuery)
        Creates an exists predicate that tests if a given subquery returns any row
        Parameters:
        subQuery - the subquery that performs the existence test
        Returns:
        the exists predicate
      • now

        static Value<Instant> now()
        Creates an ElementRef to be used in queries to represent $now.
        Returns:
        the now value
      • validFrom

        static Value<Instant> validFrom()
        Creates an ElementRef on the available $validFrom value.
        Returns:
        the validFrom value
      • validTo

        static Value<Instant> validTo()
        Creates an ElementRef on the available $validTo value.
        Returns:
        the validTo value
      • userLocale

        static Value<String> userLocale()
        Creates an ElementRef on the available $user.locale value.
        Returns:
        the locale string value
      • userId

        static Value<String> userId()
        Creates an ElementRef on the available $user.id value.
        Returns:
        the user.id value
      • list

        static CqnToken list​(List<? extends CqnValue> values)
        Creates a CqnListValue composing given values
        Parameters:
        values - the components
        Returns:
        the list value
      • matching

        static Predicate matching​(Map<String,​?> elementToValueMap)
        Creates a predicate from a map of element names to values or parameters. The map entries are transformed into equality predicates and joined via and.
        Parameters:
        elementToValueMap - the element name to value map defining the condition
        Returns:
        the matching predicate