public class ValidatorUtils extends Object
| Constructor and Description |
|---|
ValidatorUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
handleValidationError(EventContext context,
CdsErrorStatuses statuses,
Object... args)
Handles the given
CdsErrorStatuses by either generating an error
message or throwing a ErrorStatusException. |
static boolean |
isNullNotAllowed(com.sap.cds.reflect.CdsElement element,
Predicate<com.sap.cds.reflect.CdsElement> isNullNotAllowed)
Checks whether the given cds element is not allowed to be null.
|
static void |
runNullElementCheck(EventContext context,
Predicate<Object> isNull,
Predicate<com.sap.cds.reflect.CdsElement> isNullNotAllowed,
BiConsumer<Map.Entry<com.sap.cds.reflect.CdsElement,com.sap.cds.reflect.CdsElement>,com.sap.cds.reflect.CdsStructuredType> errorHandler)
Generic method that checks a given event context for null elements, utilizing
the provided functions for the null element validation and the provided error
handler in case of a failed validation.
|
public static void runNullElementCheck(EventContext context, Predicate<Object> isNull, Predicate<com.sap.cds.reflect.CdsElement> isNullNotAllowed, BiConsumer<Map.Entry<com.sap.cds.reflect.CdsElement,com.sap.cds.reflect.CdsElement>,com.sap.cds.reflect.CdsStructuredType> errorHandler)
context - the event contextisNull - predicate that returns true if the provided object is
nullisNullNotAllowed - predicate that returns true if the provided CDS
element is not allowed to be nullerrorHandler - handles the error if validation failspublic static boolean isNullNotAllowed(com.sap.cds.reflect.CdsElement element,
Predicate<com.sap.cds.reflect.CdsElement> isNullNotAllowed)
element - the element to validateisNullNotAllowed - a predicate that returns true if the given cds
element is not allowed to be nullnullpublic static void handleValidationError(EventContext context, CdsErrorStatuses statuses, Object... args)
CdsErrorStatuses by either generating an error
message or throwing a ErrorStatusException.context - the event contextstatuses - the cds error statusargs - message argsCopyright © 2021. All rights reserved.