Class StructuredQuery
java.lang.Object
com.sap.cloud.sdk.datamodel.odata.client.query.StructuredQuery
- All Implemented Interfaces:
QuerySerializable
StructuredQuery acts as a builder for OData 2.0 or 4.0 queries. It assists with assembling request parameters
such as $select, $filter, .... This API does not differentiate between OData versions. Only leveraging
features e.g. within filters that conform to the selected protocol version is the responsibility of the consumer.-
Method Summary
Modifier and TypeMethodDescriptionstatic StructuredQueryasNestedQueryOnProperty(String fieldName, ODataProtocol protocol) Create a nested query on a property.filter(ValueBoolean... filters) Compute the encoded string representation of this query.The structured property field name.Compute the string representation of this query.getSkip()getTop()booleanisRoot()static StructuredQueryonEntity(String entityName, ODataProtocol protocol) Create aStructuredQueryfor building up OData 2.0 or 4.0 queries.orderBy(OrderExpression ordering) select(StructuredQuery... subqueries) Query modifier to limit which complex and navigational properties will be expanded (and thus selected).Query modifier to limit which field values of the entity get fetched and populated.withCustomParameter(String key, String value) Adds a custom query parameter in the form of a key=value pair.Requests an inline count by adding the system query option$inlinecount(OData V2) or$count(OData V4).
-
Method Details
-
onEntity
@Nonnull public static StructuredQuery onEntity(@Nonnull String entityName, @Nonnull ODataProtocol protocol) Create aStructuredQueryfor building up OData 2.0 or 4.0 queries.- Parameters:
entityName- The entity collection to be queried.protocol- TheODataProtocolversion this query should conform to.- Returns:
- A new
StructuredQueryobject.
-
asNestedQueryOnProperty
@Nonnull public static StructuredQuery asNestedQueryOnProperty(@Nonnull String fieldName, @Nonnull ODataProtocol protocol) Create a nested query on a property. This is an OData 4.0 specific feature.- Parameters:
fieldName- The property that is to be queried.protocol- TheODataProtocolversion this query should conform to.- Returns:
- A new
StructuredQueryobject.
-
select
Query modifier to limit which field values of the entity get fetched and populated.- Parameters:
fields- Properties to be selected.- Returns:
- This query object with the added selections.
-
select
Query modifier to limit which complex and navigational properties will be expanded (and thus selected). Such expansions are represented again through structured queries.- Parameters:
subqueries- Query objects on properties to be expanded. ThegetEntityOrPropertyName()will be th- Returns:
- This query object with the added selections.
-
filter
-
top
-
skip
-
orderBy
-
orderBy
-
search
-
withCustomParameter
Adds a custom query parameter in the form of a key=value pair. This will not override any parameters set viaselect,filteretc.- Parameters:
key- The parameter key. Must not be null or empty.value- The parameter value.- Returns:
- This query object with the added parameter
- Throws:
IllegalArgumentException- if the key is null or emptyIllegalStateException- if this query object is a nested query
-
withInlineCount
Requests an inline count by adding the system query option$inlinecount(OData V2) or$count(OData V4).- Returns:
- This query object with the added parameter
-
getEncodedQueryString
Description copied from interface:QuerySerializableCompute the encoded string representation of this query. All characters except the ones listed inODataUriFactory#SAFE_CHARS_IN_QUERYare encoded- Specified by:
getEncodedQueryStringin interfaceQuerySerializable- Returns:
- A string representing the encoded request query.
-
getQueryString
Description copied from interface:QuerySerializableCompute the string representation of this query.- Specified by:
getQueryStringin interfaceQuerySerializable- Returns:
- A string representing the request query.
-
getEntityOrPropertyName
The structured property field name. -
isRoot
public boolean isRoot() -
getProtocol
-
getSimpleSelectors
-
getComplexSelectors
-
getFilters
-
getCustomParameters
-
getOrderBy
-
getTop
-
getSkip
-
getSearch
-