Package com.sap.cds
Interface CdsDataProcessor
@Beta
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 interfaceFunction to convert or remove a value for a CdsElement.static interfacestatic interfacePredicate to filter a CdsElement by the element's CdsType.static interfaceFunction to compute a value for a CdsElement.static enumThe processing mode:CdsDataProcessor.Mode.DECLARED,CdsDataProcessor.Mode.CONTAINS,CdsDataProcessor.Mode.NOT_NULLorCdsDataProcessor.Mode.NULL.static interfaceFunction to validate the value of a CdsElement. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ObjectIndicates 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 CdsDataProcessoraddValidator(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 CdsDataProcessorcreate()Creates a new DataProcessor instance.default voidRuns the CdsDataProcessor on the given CDS.ql result.voidRuns the CdsDataProcessor on the given data entries.voidprocess(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.FiltervalConverter- 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.FiltervalGenerator- the ValueCdsDataProcessor.Generatorfunction- 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.Filtervalidator- 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.Filtervalidator- the validation function, seeCdsDataProcessor.Validatormode- 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
-