Package com.sap.cds.ql
Interface CQL
public interface CQL
-
Field Summary
Modifier and TypeFieldDescriptionstatic final BooleanValue
static final NullValue
static final BooleanValue
-
Method Summary
Modifier and TypeMethodDescriptionstatic Predicate
and
(CqnPredicate p1, CqnPredicate p2) Creates a conjunction of two given predicatesstatic Predicate
and
(Iterable<? extends CqnPredicate> predicates) Creates a conjunction of given predicatesCreates an average function call on the given element or expression.static BooleanFunction
booleanFunc
(String name, List<? extends CqnValue> args) Creates a CDS QL function call that is send to the underlying data store.static Predicate
comparison
(CqnValue lhs, CqnComparisonPredicate.Operator op, CqnValue rhs) Creates a comparison predicate.static Predicate
connect
(CqnConnectivePredicate.Operator operator, Iterable<? extends CqnPredicate> predicates) Creates a logical connection of given predicatesCqnPredicate
.static <T> Literal<T>
constant
(T value) 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 positionCqnContainmentTest.Position
static Predicate
Creates a predicate that tests whether a string value contains a given substringstatic RefBuilder<ElementRef<?>>
copy
(CqnElementRef ref) Creates aRefBuilder
from the given ref, which allows for in-place modification of the ref.static Expand<?>
Creates a copy of the given expand.static Predicate
copy
(CqnPredicate pred) Creates a copy of the given predicate.static Predicate
copy
(CqnPredicate pred, Modifier modifier) Creates a modified copy of the given predicate.static RefBuilder<StructuredTypeRef>
copy
(CqnStructuredTypeRef ref) Creates aRefBuilder
from the given ref, which allows for in-place modification of the ref.static <S extends CqnStatement>
Scopy
(S statement) Creates a copy of the given CQN statement.static <S extends CqnStatement>
SCreates a modified copy of the given CQN statement.count()
Creates a count all function call.count
(CqnElementRef element) Creates a count function call on the given element.countDistinct
(CqnValue value) Creates an count distinct function call on the given element or expression.static Predicate
Creates a predicate that tests whether a string value ends with a given suffixstatic StructuredType<?>
Creates aStructuredType
representing a CDS entity.static Predicate
Creates an exists predicate that tests if a given subquery returns any rowexpression
(CqnValue left, CqnArithmeticExpression.Operator op, CqnValue right) Creates an arithmetic expression.static <T> FunctionCall<T>
Creates a CDS QL function call that is send to the underlying data store.static <T> FunctionCall<T>
Creates a CDS QL function call that is send to the underlying data store.static <T> ElementRef<T>
Creates anElementRef
representing a path from a CDS entity to an element of this or another entity.static <T> ElementRef<T>
get
(List<? extends CqnReference.Segment> segments) Creates anElementRef
representing a path from a CDS entity to an element of this or another entity.static Predicate
Creates anin
predicate.static Predicate
in
(CqnValue value, Collection<? extends CqnValue> values) Creates anin
predicate.static CqnListValue
Creates aCqnListValue
composing given valuesstatic CqnListValue
Creates aCqnListValue
composing given valuesstatic Predicate
match
(CqnStructuredTypeRef ref, CqnPredicate pred, CqnMatchPredicate.Quantifier quantifier) Creates a match predicate that tests if a given ref matches a given filterstatic Predicate
Creates a predicate from a map of element names to values or parameters.static <T> Value<T>
Creates a max function call on the given element or expression.static <T> Value<T>
Creates a min function call on the given element or expression.static Predicate
not
(CqnPredicate predicate) Negates a givenCqnPredicate
.now()
Creates anElementRef
to be used in queries to represent $now.static Predicate
or
(CqnPredicate p1, CqnPredicate p2) Creates a disjunction of two given predicatesstatic Predicate
or
(Iterable<? extends CqnPredicate> predicates) Creates a disjunction of given predicatesstatic <T> Parameter<T>
param
(int index) Creates an indexedParameter
to be used in CQN statements.static <T> Parameter<T>
Creates a namedParameter
to be used in queries.static Value<?>
Creates a CQN plain value, which is directly send to the underlying data store.static CqnReference.Segment
refSegment
(String id) Creates a segment of a structured type or element reference without filter.static CqnReference.Segment
refSegment
(String id, CqnPredicate filter) Creates a segment of a structured type or element reference with a filter condition.static List<CqnReference.Segment>
refSegments
(List<String> segmentIds) Creates a list of reference segments without filter.static Predicate
Creates a search predicate.static CqnSortSpecification
sort
(CqnValue value, CqnSortSpecification.Order order) Creates aCqnSortSpecification
that sorts a value by a given orderstatic CqnStar
star()
static Predicate
startsWith
(CqnValue value, CqnValue prefix, boolean caseInsensitive) Creates a predicate that tests whether a string value starts with a given prefixCreates a sum function call on the given element or expression.static StructuredType<?>
Creates aStructuredType
representing a path from a CDS entity to another entity.static StructuredType<?>
to
(List<? extends CqnReference.Segment> segments) Creates aStructuredType
representing a path from a CDS entity to another entity.Creates a CDS QL expression for converting the given string value to lower case using the rules of the underlying data store.Creates a CDS QL expression for converting the given string value to lower case using the rules of the underlying data store.Creates a CDS QL expression for converting the given string value to upper case using the rules of the underlying data store.Creates a CDS QL expression for converting the given string value to upper case using the rules of the underlying data store.userId()
Creates anElementRef
on the available $user.id value.Creates anElementRef
on the available $user.locale value.static <T> Literal<T>
val
(T value) Creates anElementRef
on the available $validFrom value.validTo()
Creates anElementRef
on the available $validTo value.static Collector<CqnPredicate,
?, CqnPredicate> withAnd()
Returns aCollector
that connects the input predicates with AND.static Collector<CqnPredicate,
?, CqnPredicate> withOr()
Returns aCollector
that connects the input predicates with OR.
-
Field Details
-
TRUE
-
FALSE
-
NULL
-
-
Method Details
-
copy
Creates aRefBuilder
from the given ref, which allows for in-place modification of the ref.- Parameters:
ref
- the ref to be copied- Returns:
- the ref builder
-
copy
Creates aRefBuilder
from the given ref, which allows for in-place modification of the ref.- Parameters:
ref
- the element ref to be copied- Returns:
- the ref builder
-
copy
Creates a copy of the given expand.- Parameters:
expand
- the expand to be copied- Returns:
- the copy
-
copy
Creates a copy of the given predicate.- Parameters:
pred
- the predicate to be copied- Returns:
- the copy
-
copy
Creates a modified copy of the given predicate.- Parameters:
pred
- the predicate to be copiedmodifier
- the modifier for altering the copy- Returns:
- the modified copy
-
copy
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
Creates a modified copy of the given CQN statement.- Type Parameters:
S
- the type of CqnStatement- Parameters:
statement
- the CQN statement to be copiedmodifier
- the modifier for altering the copy- Returns:
- the modified copy
-
func
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 calledargs
- the arguments of the function- Returns:
- the CDS QL function call
-
func
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 calledargs
- the arguments of the function- Returns:
- the CDS QL function call
-
booleanFunc
Creates a CDS QL function call that is send to the underlying data store.- Parameters:
name
- the name of the function to be calledargs
- the arguments of the function- Returns:
- the CDS QL function call
-
constant
- Type Parameters:
T
- the type of the constant- Parameters:
value
- the value- Returns:
- the constant
-
val
- Type Parameters:
T
- the type of the non-constant value- Parameters:
value
- the value of the non-constant value- Returns:
- the value
- See Also:
-
not
Negates a givenCqnPredicate
.- Parameters:
predicate
- theCqnPredicate
to be negated- Returns:
- the negated predicate
-
and
Creates a conjunction of two given predicates- Parameters:
p1
- 1st operand of the conjunctionp2
- 2nd operand of the conjunction- Returns:
- the conjunction
-
withAnd
Returns aCollector
that connects the input predicates with AND. If there are none theCollector
returns TRUE.- Returns:
- the collector
-
or
Creates a disjunction of two given predicates- Parameters:
p1
- 1st operand of the disjunctionp2
- 2nd operand of the disjunction- Returns:
- the disjunction
-
and
Creates a conjunction of given predicates- Parameters:
predicates
- the predicates to connect- Returns:
- the conjunction
-
or
Creates a disjunction of given predicates- Parameters:
predicates
- the predicates to connect- Returns:
- the disjunction
-
withOr
Returns aCollector
that connects the input predicates with OR. If there are none theCollector
returns FALSE.- Returns:
- the collector
-
connect
static Predicate connect(CqnConnectivePredicate.Operator operator, Iterable<? extends CqnPredicate> predicates) Creates a logical connection of given predicatesCqnPredicate
.- Parameters:
operator
- operator to connect the predicates withpredicates
- the predicates to connect- Returns:
- the logical connection
-
param
Creates an indexedParameter
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
Creates a namedParameter
to be used in queries.- Type Parameters:
T
- the type of the parameter- Parameters:
name
- the parameter name- Returns:
- the parameter
-
plain
Creates a CQN plain value, which is directly send to the underlying data store.- Parameters:
value
- the value content- Returns:
- the plain value
-
count
Creates a count all function call.- Returns:
- the count value
-
count
Creates a count function call on the given element.- Parameters:
element
- the ref to the element to be counted- Returns:
- the count value
-
min
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
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
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
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
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
Creates a predicate that tests whether a string value contains a given substring- Parameters:
value
- the string valuesubstring
- the substring to test forcaseInsensitive
- whether the test should be case insensitive- Returns:
- the predicate for the containment test
-
startsWith
Creates a predicate that tests whether a string value starts with a given prefix- Parameters:
value
- the string valueprefix
- the prefix to test forcaseInsensitive
- whether the test should be case insensitive- Returns:
- the predicate for the containment test
-
endsWith
Creates a predicate that tests whether a string value ends with a given suffix- Parameters:
value
- the string valuesuffix
- the suffix to test forcaseInsensitive
- 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 positionCqnContainmentTest.Position
- Parameters:
position
- the positionvalue
- the string valuesubstring
- the substring to test forcaseInsensitive
- whether the test should be case insensitive- Returns:
- the predicate for the containment test
-
toLower
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
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
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
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
Creates aStructuredType
representing a CDS entity.- Parameters:
qualifiedName
- the qualified name of the CDS entity- Returns:
- the
StructuredType
representing the CDS entity
-
to
Creates aStructuredType
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
Creates aStructuredType
representing a path from a CDS entity to another entity. To create aStructuredTypeRef
, useCQL.to(segments).asRef()
.- Parameters:
segments
- the segments of the path- Returns:
- the
StructuredType
representing the path to a CDS entity
-
get
Creates anElementRef
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
Creates anElementRef
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
Creates a segment of a structured type or element reference without filter. UserefSegment(String, CqnPredicate)
to create a segment with filter condition.- Parameters:
id
- the id of the segment- Returns:
- the segment
-
refSegment
Creates a segment of a structured type or element reference with a filter condition.- Parameters:
id
- the id of the segmentfilter
- the filter of the segment- Returns:
- the segment
-
refSegments
Creates a list of reference segments without filter.- Parameters:
segmentIds
- the ids of the segments- Returns:
- the segments
-
expression
Creates an arithmetic expression.- Parameters:
left
- the left-hand side of the expressionop
- the operatorright
- the right-hand side of the expression- Returns:
- the arithmetic expression
-
comparison
Creates a comparison predicate.- Parameters:
lhs
- the left-hand side of the comparisonop
- the comparison operatorrhs
- the right-hand side of the comparison- Returns:
- the comparison predicate
-
in
Creates anin
predicate.- Parameters:
value
- the value to be checked if it's contained in the collectionvalues
- the collection of values- Returns:
- the
in
predicate
-
in
Creates anin
predicate.- Parameters:
value
- the value to be checked if it's contained in the collectionvalueSet
- the value describing a collection of values- Returns:
- the
in
predicate
-
search
Creates a search predicate.- Parameters:
term
- the search term- Returns:
- the search predicate
-
exists
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
-
match
static Predicate match(CqnStructuredTypeRef ref, CqnPredicate pred, CqnMatchPredicate.Quantifier quantifier) Creates a match predicate that tests if a given ref matches a given filter- Parameters:
ref
- the referencepred
- the filterquantifier
- all or any- Returns:
- the match predicate
-
now
Creates anElementRef
to be used in queries to represent $now.- Returns:
- the now value
-
validFrom
Creates anElementRef
on the available $validFrom value.- Returns:
- the validFrom value
-
validTo
Creates anElementRef
on the available $validTo value.- Returns:
- the validTo value
-
userLocale
Creates anElementRef
on the available $user.locale value.- Returns:
- the locale string value
-
userId
Creates anElementRef
on the available $user.id value.- Returns:
- the user.id value
-
star
-
list
Creates aCqnListValue
composing given values- Parameters:
values
- the components- Returns:
- the list value
-
list
Creates aCqnListValue
composing given values- Parameters:
values
- the items- Returns:
- the list value
-
matching
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
-
sort
Creates aCqnSortSpecification
that sorts a value by a given order- Parameters:
value
- the valueorder
- the order- Returns:
- the sort specification
-