Interface ValidationContext
-
- All Known Implementing Classes:
ValidationContextImpl
public interface ValidationContext
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description ValidationContextapply(ValidationFunction.Basic validator)ValidationContextapply(ValidationFunction.Typed<java.lang.String> validator)<T> ValidationContextapply(ValidationFunction.Typed<T> validator, java.lang.Class<T> targetClass)<T,U>
ValidationContextapply(ValidationFunction.TypedArg<T,U> validator, java.lang.Class<T> targetClass, U arg)ValidationContextapply(ValidationFunction.Version<java.lang.Object> validator)<T> ValidationContextapply(ValidationFunction.Version<T> validator, java.lang.Class<T> targetClass)ValidationContextapplyIf(boolean condition, ValidationFunction.Basic validator)ValidationContextapplyIf(boolean condition, ValidationFunction.Typed<java.lang.String> validator)<T> ValidationContextapplyIf(boolean condition, ValidationFunction.Typed<T> validator, java.lang.Class<T> targetClass)<T,U>
ValidationContextapplyIf(boolean condition, ValidationFunction.TypedArg<T,U> validator, java.lang.Class<T> targetClass, U arg)<T> ValidationContextapplyIf(boolean condition, ValidationFunction.Version<T> validator, java.lang.Class<T> targetClass)ValidationContextapplyMapKeys(ValidationFunction.Basic validator)ValidationContextapplyMapKeys(ValidationFunction.Typed<java.lang.String> validator)<U> ValidationContextapplyMapKeys(ValidationFunction.TypedArg<java.lang.String,U> validator, U arg)<T> ValidationContextapplyMapValues(ValidationFunction.Basic validator)<T> ValidationContextapplyMapValues(ValidationFunction.Typed<T> validator, java.lang.Class<T> targetClass)<T,U>
ValidationContextapplyMapValues(ValidationFunction.TypedArg<T,U> validator, java.lang.Class<T> targetClass, U arg)ValidationContextapplyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Basic validator)<T> ValidationContextapplyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Typed<T> validator, java.lang.Class<T> targetClass)<T,U>
ValidationContextapplyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.TypedArg<T,U> validator, java.lang.Class<T> targetClass, U arg)<T> ValidationContextapplyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Version<T> validator, java.lang.Class<T> targetClass)ValidationContextapplyRegistered()ValidationContextapplyRepeated(ValidationFunction.Basic validator)ValidationContextapplyRepeated(ValidationFunction.Typed<java.lang.String> validator)<T> ValidationContextapplyRepeated(ValidationFunction.Typed<T> validator, java.lang.Class<T> targetClass)<T,U>
ValidationContextapplyRepeated(ValidationFunction.TypedArg<T,U> validator, java.lang.Class<T> targetClass, U arg)booleandone()ValidationContexterror(java.lang.String message)Record an error against the current location in the validation stackbooleanfailed()com.google.protobuf.Descriptors.FieldDescriptorfield()java.lang.StringfieldName()static ValidationContextforMessage(com.google.protobuf.Message msg)static ValidationContextforMethod(com.google.protobuf.Message msg, com.google.protobuf.Descriptors.MethodDescriptor descriptor)static ValidationContextforVersion(com.google.protobuf.Message current, com.google.protobuf.Message prior)java.util.List<ValidationFailure>getErrors()booleanisMap()booleanisOneOf()booleanisRepeated()ValidationKeykey()com.google.protobuf.Descriptors.OneofDescriptoroneOf()com.google.protobuf.MessageparentMsg()ValidationContextpop()Pop the current object from the validation stackValidationContextprior()ValidationContextpush(com.google.protobuf.Descriptors.FieldDescriptor field)Push a member field of the current object onto the validation stackValidationContextpushMap(com.google.protobuf.Descriptors.FieldDescriptor mapField)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, java.util.function.Function<TMsg,java.util.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.ValidationContextpushMapKey(java.lang.Object key)Push an individual map key onto the validation stack Requires that the current target is a map field.ValidationContextpushMapValue(java.lang.Object key)Push an individual map value onto the validation stack Requires that the current target is a map field.ValidationContextpushOneOf(com.google.protobuf.Descriptors.OneofDescriptor oneOfField)Push a "one-of" field of the current object onto the validation stackValidationContextpushRepeated(com.google.protobuf.Descriptors.FieldDescriptor repeatedField)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.ValidationContextpushRepeatedItem(int index)Push an individual list item onto the validation stack Requires that the current target is a repeated field.ValidationContextpushRepeatedItem(int index, java.lang.Object priorObject)Push an individual list item onto the validation stack Requires that the current target is a repeated field.ValidationContextpushRepeatedItem(java.lang.Object obj, java.lang.Object priorObject)Push an individual list item onto the validation stack Requires that the current target is a repeated field.ValidationContextskip()Skip the current location in the validation stack Any future calls to apply() at this location or child locations will be ignored.booleanskipped()java.lang.Objecttarget()ValidationTypevalidationType()
-
-
-
Method Detail
-
forMethod
static ValidationContext forMethod(com.google.protobuf.Message msg, com.google.protobuf.Descriptors.MethodDescriptor descriptor)
-
forMessage
static ValidationContext forMessage(com.google.protobuf.Message msg)
-
forVersion
static ValidationContext forVersion(com.google.protobuf.Message current, com.google.protobuf.Message prior)
-
push
ValidationContext push(com.google.protobuf.Descriptors.FieldDescriptor field)
Push a member field of the current object onto the validation stack- Parameters:
field- The field that will be pushed onto the stack- Returns:
- A validation context pointing at the field that has been pushed
-
pushOneOf
ValidationContext pushOneOf(com.google.protobuf.Descriptors.OneofDescriptor oneOfField)
Push a "one-of" field of the current object onto the validation stack- Parameters:
oneOfField- The one-of field that will be pushed onto the stack- Returns:
- A validation context pointing at the field that has been pushed
-
pushRepeated
ValidationContext pushRepeated(com.google.protobuf.Descriptors.FieldDescriptor repeatedField)
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. To push individual list items, use pushRepeatedItem() after calling this method.- Parameters:
repeatedField- The field that will be pushed onto the stack- Returns:
- A validation context pointing at the list that has been pushed
-
pushRepeatedItem
ValidationContext pushRepeatedItem(int index)
Push an individual list item onto the validation stack Requires that the current target is a repeated field.- 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
ValidationContext pushRepeatedItem(int index, java.lang.Object priorObject)
Push 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.- Parameters:
index- The index of the list item to push onto the stack (must be within bounds of the list)priorObject- 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
ValidationContext pushRepeatedItem(java.lang.Object obj, java.lang.Object priorObject)
Push 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.- Parameters:
obj- The current list item to push onto the stack (must be a member of the list)priorObject- 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
<TMsg extends com.google.protobuf.Message> ValidationContext pushMap(com.google.protobuf.Descriptors.FieldDescriptor mapField, java.util.function.Function<TMsg,java.util.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. 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).- 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)
-
pushMap
ValidationContext pushMap(com.google.protobuf.Descriptors.FieldDescriptor mapField)
Push 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).- Parameters:
mapField- 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)
-
pushMapKey
ValidationContext pushMapKey(java.lang.Object key)
Push an individual map key onto the validation stack Requires that the current target is a map field.- Parameters:
key- The map key to push onto the stack- Returns:
- A validation context pointing at the map key that has been pushed
-
pushMapValue
ValidationContext pushMapValue(java.lang.Object key)
Push an individual map value onto the validation stack Requires that the current target is a map field.- 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
ValidationContext pop()
Pop the current object from the validation stack- Returns:
- A validation context pointing at the parent of the current object
-
error
ValidationContext error(java.lang.String message)
Record an error against the current location in the validation stack- Parameters:
message- The error message to record- Returns:
- A validation context which includes the recorded error
-
skip
ValidationContext skip()
Skip 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.- Returns:
- A validation context with the current object marked as skipped
-
applyRegistered
ValidationContext applyRegistered()
-
apply
ValidationContext apply(ValidationFunction.Basic validator)
-
apply
ValidationContext apply(ValidationFunction.Typed<java.lang.String> validator)
-
apply
<T> ValidationContext apply(ValidationFunction.Typed<T> validator, java.lang.Class<T> targetClass)
-
apply
<T,U> ValidationContext apply(ValidationFunction.TypedArg<T,U> validator, java.lang.Class<T> targetClass, U arg)
-
apply
ValidationContext apply(ValidationFunction.Version<java.lang.Object> validator)
-
apply
<T> ValidationContext apply(ValidationFunction.Version<T> validator, java.lang.Class<T> targetClass)
-
applyIf
ValidationContext applyIf(boolean condition, ValidationFunction.Basic validator)
-
applyIf
ValidationContext applyIf(boolean condition, ValidationFunction.Typed<java.lang.String> validator)
-
applyIf
<T> ValidationContext applyIf(boolean condition, ValidationFunction.Typed<T> validator, java.lang.Class<T> targetClass)
-
applyIf
<T,U> ValidationContext applyIf(boolean condition, ValidationFunction.TypedArg<T,U> validator, java.lang.Class<T> targetClass, U arg)
-
applyIf
<T> ValidationContext applyIf(boolean condition, ValidationFunction.Version<T> validator, java.lang.Class<T> targetClass)
-
applyOneOf
ValidationContext applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Basic validator)
-
applyOneOf
<T> ValidationContext applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Typed<T> validator, java.lang.Class<T> targetClass)
-
applyOneOf
<T,U> ValidationContext applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.TypedArg<T,U> validator, java.lang.Class<T> targetClass, U arg)
-
applyOneOf
<T> ValidationContext applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Version<T> validator, java.lang.Class<T> targetClass)
-
applyRepeated
ValidationContext applyRepeated(ValidationFunction.Basic validator)
-
applyRepeated
ValidationContext applyRepeated(ValidationFunction.Typed<java.lang.String> validator)
-
applyRepeated
<T> ValidationContext applyRepeated(ValidationFunction.Typed<T> validator, java.lang.Class<T> targetClass)
-
applyRepeated
<T,U> ValidationContext applyRepeated(ValidationFunction.TypedArg<T,U> validator, java.lang.Class<T> targetClass, U arg)
-
applyMapKeys
ValidationContext applyMapKeys(ValidationFunction.Basic validator)
-
applyMapKeys
ValidationContext applyMapKeys(ValidationFunction.Typed<java.lang.String> validator)
-
applyMapKeys
<U> ValidationContext applyMapKeys(ValidationFunction.TypedArg<java.lang.String,U> validator, U arg)
-
applyMapValues
<T> ValidationContext applyMapValues(ValidationFunction.Basic validator)
-
applyMapValues
<T> ValidationContext applyMapValues(ValidationFunction.Typed<T> validator, java.lang.Class<T> targetClass)
-
applyMapValues
<T,U> ValidationContext applyMapValues(ValidationFunction.TypedArg<T,U> validator, java.lang.Class<T> targetClass, U arg)
-
validationType
ValidationType validationType()
-
key
ValidationKey key()
-
target
java.lang.Object target()
-
parentMsg
com.google.protobuf.Message parentMsg()
-
isOneOf
boolean isOneOf()
-
isRepeated
boolean isRepeated()
-
isMap
boolean isMap()
-
oneOf
com.google.protobuf.Descriptors.OneofDescriptor oneOf()
-
field
com.google.protobuf.Descriptors.FieldDescriptor field()
-
fieldName
java.lang.String fieldName()
-
prior
ValidationContext prior()
-
failed
boolean failed()
-
skipped
boolean skipped()
-
done
boolean done()
-
getErrors
java.util.List<ValidationFailure> getErrors()
-
-