Package com.sap.cds
Interface CdsDataProcessor
public interface CdsDataProcessor
The CdsDataProcessor allows to process deeply nested maps of CDS data, by
executing a sequence of registered handlers of type
CdsDataProcessor.Generator
,
CdsDataProcessor.Converter
or CdsDataProcessor.Validator
.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Function to convert or remove a value for a CdsElement.static interface
static interface
Predicate to filter a CdsElement by the element's CdsType.static interface
Function to compute a value for a CdsElement.static enum
The processing mode:CdsDataProcessor.Mode.DECLARED
,CdsDataProcessor.Mode.CONTAINS
,CdsDataProcessor.Mode.NOT_NULL
orCdsDataProcessor.Mode.NULL
.static interface
Function to validate the value of a CdsElement. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Object
Indicates the absence of a value in the data map.static final CdsDataProcessor.Factory
-
Method Summary
Modifier and TypeMethodDescriptionaddConverter
(CdsDataProcessor.Filter filter, CdsDataProcessor.Converter valConverter) Adds a function to convert values of elements that match a given filter.addGenerator
(CdsDataProcessor.Filter filter, CdsDataProcessor.Generator valGenerator) Adds a function to generate values for elements that match a given filter and are missing in the data or mapped to null.default CdsDataProcessor
addValidator
(CdsDataProcessor.Filter filter, CdsDataProcessor.Validator validator) Adds a function to validate values of elements that match a given filter.addValidator
(CdsDataProcessor.Filter filter, CdsDataProcessor.Validator validator, CdsDataProcessor.Mode mode) Adds a function to validate values of elements that match a given filter.static CdsDataProcessor
create()
Creates a new DataProcessor instance.default void
Runs the CdsDataProcessor on the given CDS.ql result.void
Runs the CdsDataProcessor on the given data entries.void
process
(Map<String, Object> entry, CdsStructuredType entryType) Runs the CdsDataProcessor on the given data entry.
-
Field Details
-
factory
-
ABSENT
Indicates the absence of a value in the data map.
-
-
Method Details
-
create
Creates a new DataProcessor instance.- Returns:
- a DataProcessor
-
addConverter
CdsDataProcessor addConverter(CdsDataProcessor.Filter filter, CdsDataProcessor.Converter valConverter) Adds a function to convert values of elements that match a given filter.- Parameters:
filter
- the filter predicate, seeCdsDataProcessor.Filter
valConverter
- the value converter function, seeCdsDataProcessor.Converter
- Returns:
- this DataProcessor
-
addGenerator
CdsDataProcessor addGenerator(CdsDataProcessor.Filter filter, CdsDataProcessor.Generator valGenerator) Adds a function to generate values for elements that match a given filter and are missing in the data or mapped to null.- Parameters:
filter
- the filter predicate, seeCdsDataProcessor.Filter
valGenerator
- the ValueCdsDataProcessor.Generator
function- Returns:
- this DataProcessor
-
addValidator
default CdsDataProcessor addValidator(CdsDataProcessor.Filter filter, CdsDataProcessor.Validator validator) Adds a function to validate values of elements that match a given filter. The validator function is only called for elements that have an associated value (including null) in the data map, this can be changed by providing a processing mode viaaddValidator(Filter, Validator, Mode)
- Parameters:
filter
- the filter predicate, seeCdsDataProcessor.Filter
validator
- the validation function, seeCdsDataProcessor.Validator
- Returns:
- this DataProcessor
-
addValidator
CdsDataProcessor addValidator(CdsDataProcessor.Filter filter, CdsDataProcessor.Validator validator, CdsDataProcessor.Mode mode) Adds a function to validate values of elements that match a given filter.- Parameters:
filter
- the filter predicate, seeCdsDataProcessor.Filter
validator
- the validation function, seeCdsDataProcessor.Validator
mode
- the processingCdsDataProcessor.Mode
- Returns:
- this DataProcessor
-
process
Runs the CdsDataProcessor on the given data entry.- Parameters:
entry
- the data entryentryType
- the CDS type of the data entry
-
process
Runs the CdsDataProcessor on the given data entries.- Parameters:
entries
- the data entriesentryType
- the CDS type of the data entries
-
process
Runs the CdsDataProcessor on the given CDS.ql result.- Parameters:
result
- the CDS.ql result
-