Class ValidationContextImpl
java.lang.Object
org.finos.tracdap.common.validation.core.impl.ValidationContextImpl
- All Implemented Interfaces:
ValidationContext
-
Method Summary
Modifier and TypeMethodDescriptionapply(ValidationFunction.Basic validator) apply(ValidationFunction.Typed<String> validator) apply(ValidationFunction.Typed<T> validator, Class<T> targetClass) <T,U> ValidationContext apply(ValidationFunction.TypedArg<T, U> validator, Class<T> targetClass, U arg) apply(ValidationFunction.Version<Object> validator) apply(ValidationFunction.Version<T> validator, Class<T> targetClass) applyIf(boolean condition, ValidationFunction.Basic validator) applyIf(boolean condition, ValidationFunction.Typed<String> validator) applyIf(boolean condition, ValidationFunction.Typed<T> validator, Class<T> targetClass) <T,U> ValidationContext applyIf(boolean condition, ValidationFunction.TypedArg<T, U> validator, Class<T> targetClass, U arg) applyIf(boolean condition, ValidationFunction.Version<T> validator, Class<T> targetClass) applyMapKeys(ValidationFunction.Basic validator) applyMapKeys(ValidationFunction.Typed<String> validator) applyMapKeys(ValidationFunction.TypedArg<String, U> validator, U arg) applyMapValues(ValidationFunction.Basic validator) applyMapValues(ValidationFunction.Typed<T> validator, Class<T> targetClass) <T,U> ValidationContext applyMapValues(ValidationFunction.TypedArg<T, U> validator, Class<T> targetClass, U arg) applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Basic validator) applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Typed<T> validator, Class<T> targetClass) <T,U> ValidationContext applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.TypedArg<T, U> validator, Class<T> targetClass, U arg) applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Version<T> validator, Class<T> targetClass) applyRepeated(ValidationFunction.Basic validator) applyRepeated(ValidationFunction.Typed<String> validator) applyRepeated(ValidationFunction.Typed<T> validator, Class<T> targetClass) <T,U> ValidationContext applyRepeated(ValidationFunction.TypedArg<T, U> validator, Class<T> targetClass, U arg) booleandone()Record an error against the current location in the validation stackbooleanfailed()com.google.protobuf.Descriptors.FieldDescriptorfield()static ValidationContextforMessage(com.google.protobuf.Message msg) static ValidationContextforMethod(com.google.protobuf.Message msg, com.google.protobuf.Descriptors.MethodDescriptor method) static ValidationContextforVersion(com.google.protobuf.Message current, com.google.protobuf.Message prior) booleanisMap()booleanisOneOf()booleankey()com.google.protobuf.Descriptors.OneofDescriptoroneOf()com.google.protobuf.Messagepop()Pop the current object from the validation stackprior()push(com.google.protobuf.Descriptors.FieldDescriptor fd) Push a member field of the current object onto the validation stackpushMap(com.google.protobuf.Descriptors.FieldDescriptor fd) Push a map member field of the current object onto the validation stack This method will work with applyMapKeys() and applyMapValues().<TMsg extends com.google.protobuf.Message>
ValidationContextpushMap(com.google.protobuf.Descriptors.FieldDescriptor mapField, Function<TMsg, Map<?, ?>> getMapFunc) Push a map member field of the current object onto the validation stack This method only pushes the map itself onto the stack, the validation target will be a Java Map object.pushMapKey(Object key) Push an individual map key onto the validation stack Requires that the current target is a map field.pushMapValue(Object key) Push an individual map value onto the validation stack Requires that the current target is a map field.pushOneOf(com.google.protobuf.Descriptors.OneofDescriptor oneOf) Push a "one-of" field of the current object onto the validation stackpushRepeated(com.google.protobuf.Descriptors.FieldDescriptor fd) Push a repeated member field of the current object onto the validation stack This method pushes a list onto the validation stack, so the target becomes a Java List object.pushRepeatedItem(int index) Push an individual list item onto the validation stack Requires that the current target is a repeated field.pushRepeatedItem(int index, Object priorObj) Push an individual list item onto the validation stack Requires that the current target is a repeated field.pushRepeatedItem(Object obj, Object priorObj) Push an individual list item onto the validation stack Requires that the current target is a repeated field.skip()Skip the current location in the validation stack Any future calls to apply() at this location or child locations will be ignored.booleanskipped()target()
-
Method Details
-
forMethod
public static ValidationContext forMethod(com.google.protobuf.Message msg, com.google.protobuf.Descriptors.MethodDescriptor method) -
forMessage
-
forVersion
public static ValidationContext forVersion(com.google.protobuf.Message current, com.google.protobuf.Message prior) -
push
Description copied from interface:ValidationContextPush a member field of the current object onto the validation stack- Specified by:
pushin interfaceValidationContext- Parameters:
fd- The field that will be pushed onto the stack- Returns:
- A validation context pointing at the field that has been pushed
-
pushOneOf
Description copied from interface:ValidationContextPush a "one-of" field of the current object onto the validation stack- Specified by:
pushOneOfin interfaceValidationContext- Parameters:
oneOf- The one-of field that will be pushed onto the stack- Returns:
- A validation context pointing at the field that has been pushed
-
pushRepeated
Description copied from interface:ValidationContextPush a repeated member field of the current object onto the validation stack This method pushes a list onto the validation stack, so the target becomes a Java List object. To push individual list items, use pushRepeatedItem() after calling this method.- Specified by:
pushRepeatedin interfaceValidationContext- Parameters:
fd- The field that will be pushed onto the stack- Returns:
- A validation context pointing at the list that has been pushed
-
pushRepeatedItem
Description copied from interface:ValidationContextPush an individual list item onto the validation stack Requires that the current target is a repeated field.- Specified by:
pushRepeatedItemin interfaceValidationContext- Parameters:
index- The index of the list item to push onto the stack (must be within bounds of the list)- Returns:
- A validation context pointing at the list item that has been pushed
-
pushRepeatedItem
Description copied from interface:ValidationContextPush an individual list item onto the validation stack Requires that the current target is a repeated field. This overload allows a prior version of the object to be specified for version comparison. This is helpful for version validators, which need to match current / prior entries in a list.- Specified by:
pushRepeatedItemin interfaceValidationContext- Parameters:
index- The index of the list item to push onto the stack (must be within bounds of the list)priorObj- The prior object to be compared against this list item in version validators- Returns:
- A validation context pointing at the list item that has been pushed
-
pushRepeatedItem
Description copied from interface:ValidationContextPush an individual list item onto the validation stack Requires that the current target is a repeated field. This overload allows a prior version of the object to be specified for version comparison. This is helpful for version validators, which need to match current / prior entries in a list.- Specified by:
pushRepeatedItemin interfaceValidationContext- Parameters:
obj- The current list item to push onto the stack (must be a member of the list)priorObj- The prior object to be compared against this list item in version validators- Returns:
- A validation context pointing at the list item that has been pushed
-
pushMap
Description copied from interface:ValidationContextPush a map member field of the current object onto the validation stack This method will work with applyMapKeys() and applyMapValues(). If you need to look up map items by key or want to call pushMapKey() / pushMapValue() explicitly, use the overload which takes getMapFunc as a parameter (protobuf for Java does not provide a generic way of looking up map keys).- Specified by:
pushMapin interfaceValidationContext- Parameters:
fd- The field that will be pushed onto the stack- Returns:
- A validation context pointing at the map that has been pushed (this is not a Map object)
-
pushMap
public <TMsg extends com.google.protobuf.Message> ValidationContext pushMap(com.google.protobuf.Descriptors.FieldDescriptor mapField, Function<TMsg, Map<?, ?>> getMapFunc) Description copied from interface:ValidationContextPush a map member field of the current object onto the validation stack This method only pushes the map itself onto the stack, the validation target will be a Java Map object. To push individual keys or values, use pushMapKey() or pushMapValue() after calling this method. This method needs a method reference from the parent message class to return Java map object associated with this field (protobuf for Java does not yet provide a generic way of looking up map keys).- Specified by:
pushMapin interfaceValidationContext- Parameters:
mapField- The field that will be pushed onto the stackgetMapFunc- Method reference, on the parent message to return the field as a Java map- Returns:
- A validation context pointing at the map that has been pushed (this is a Map object)
-
pushMapKey
Description copied from interface:ValidationContextPush an individual map key onto the validation stack Requires that the current target is a map field.- Specified by:
pushMapKeyin interfaceValidationContext- Parameters:
key- The map key to push onto the stack- Returns:
- A validation context pointing at the map key that has been pushed
-
pushMapValue
Description copied from interface:ValidationContextPush an individual map value onto the validation stack Requires that the current target is a map field.- Specified by:
pushMapValuein interfaceValidationContext- Parameters:
key- The key of the map value to push onto the stack- Returns:
- A validation context pointing at the map value that has been pushed
-
pop
Description copied from interface:ValidationContextPop the current object from the validation stack- Specified by:
popin interfaceValidationContext- Returns:
- A validation context pointing at the parent of the current object
-
error
Description copied from interface:ValidationContextRecord an error against the current location in the validation stack- Specified by:
errorin interfaceValidationContext- Parameters:
message- The error message to record- Returns:
- A validation context which includes the recorded error
-
skip
Description copied from interface:ValidationContextSkip the current location in the validation stack Any future calls to apply() at this location or child locations will be ignored. Errors already recorded at this location or child locations are still included in the validation report.- Specified by:
skipin interfaceValidationContext- Returns:
- A validation context with the current object marked as skipped
-
applyRegistered
- Specified by:
applyRegisteredin interfaceValidationContext
-
apply
- Specified by:
applyin interfaceValidationContext
-
apply
- Specified by:
applyin interfaceValidationContext
-
apply
- Specified by:
applyin interfaceValidationContext
-
apply
public <T,U> ValidationContext apply(ValidationFunction.TypedArg<T, U> validator, Class<T> targetClass, U arg) - Specified by:
applyin interfaceValidationContext
-
apply
- Specified by:
applyin interfaceValidationContext
-
apply
- Specified by:
applyin interfaceValidationContext
-
applyIf
- Specified by:
applyIfin interfaceValidationContext
-
applyIf
- Specified by:
applyIfin interfaceValidationContext
-
applyIf
public <T> ValidationContext applyIf(boolean condition, ValidationFunction.Typed<T> validator, Class<T> targetClass) - Specified by:
applyIfin interfaceValidationContext
-
applyIf
public <T,U> ValidationContext applyIf(boolean condition, ValidationFunction.TypedArg<T, U> validator, Class<T> targetClass, U arg) - Specified by:
applyIfin interfaceValidationContext
-
applyIf
public <T> ValidationContext applyIf(boolean condition, ValidationFunction.Version<T> validator, Class<T> targetClass) - Specified by:
applyIfin interfaceValidationContext
-
applyOneOf
public ValidationContext applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Basic validator) - Specified by:
applyOneOfin interfaceValidationContext
-
applyOneOf
public <T> ValidationContext applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Typed<T> validator, Class<T> targetClass) - Specified by:
applyOneOfin interfaceValidationContext
-
applyOneOf
public <T,U> ValidationContext applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.TypedArg<T, U> validator, Class<T> targetClass, U arg) - Specified by:
applyOneOfin interfaceValidationContext
-
applyOneOf
public <T> ValidationContext applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Version<T> validator, Class<T> targetClass) - Specified by:
applyOneOfin interfaceValidationContext
-
applyRepeated
- Specified by:
applyRepeatedin interfaceValidationContext
-
applyRepeated
- Specified by:
applyRepeatedin interfaceValidationContext
-
applyRepeated
public <T> ValidationContext applyRepeated(ValidationFunction.Typed<T> validator, Class<T> targetClass) - Specified by:
applyRepeatedin interfaceValidationContext
-
applyRepeated
public <T,U> ValidationContext applyRepeated(ValidationFunction.TypedArg<T, U> validator, Class<T> targetClass, U arg) - Specified by:
applyRepeatedin interfaceValidationContext
-
applyMapKeys
- Specified by:
applyMapKeysin interfaceValidationContext
-
applyMapKeys
- Specified by:
applyMapKeysin interfaceValidationContext
-
applyMapKeys
- Specified by:
applyMapKeysin interfaceValidationContext
-
applyMapValues
- Specified by:
applyMapValuesin interfaceValidationContext
-
applyMapValues
public <T> ValidationContext applyMapValues(ValidationFunction.Typed<T> validator, Class<T> targetClass) - Specified by:
applyMapValuesin interfaceValidationContext
-
applyMapValues
public <T,U> ValidationContext applyMapValues(ValidationFunction.TypedArg<T, U> validator, Class<T> targetClass, U arg) - Specified by:
applyMapValuesin interfaceValidationContext
-
validationType
- Specified by:
validationTypein interfaceValidationContext
-
key
- Specified by:
keyin interfaceValidationContext
-
target
- Specified by:
targetin interfaceValidationContext
-
parentMsg
public com.google.protobuf.Message parentMsg()- Specified by:
parentMsgin interfaceValidationContext
-
isOneOf
public boolean isOneOf()- Specified by:
isOneOfin interfaceValidationContext
-
isRepeated
public boolean isRepeated()- Specified by:
isRepeatedin interfaceValidationContext
-
isMap
public boolean isMap()- Specified by:
isMapin interfaceValidationContext
-
oneOf
public com.google.protobuf.Descriptors.OneofDescriptor oneOf()- Specified by:
oneOfin interfaceValidationContext
-
field
public com.google.protobuf.Descriptors.FieldDescriptor field()- Specified by:
fieldin interfaceValidationContext
-
fieldName
- Specified by:
fieldNamein interfaceValidationContext
-
prior
- Specified by:
priorin interfaceValidationContext
-
failed
public boolean failed()- Specified by:
failedin interfaceValidationContext
-
skipped
public boolean skipped()- Specified by:
skippedin interfaceValidationContext
-
done
public boolean done()- Specified by:
donein interfaceValidationContext
-
getErrors
- Specified by:
getErrorsin interfaceValidationContext
-