Interface ValidationContext

All Known Implementing Classes:
ValidationContextImpl

public interface ValidationContext
  • Method Details

    • 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, 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(Object obj, 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, 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. 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 stack
      getMapFunc - 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(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(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

      Pop the current object from the validation stack
      Returns:
      A validation context pointing at the parent of the current object
    • error

      ValidationContext error(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

      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

    • apply

    • apply

      <T> ValidationContext apply(ValidationFunction.Typed<T> validator, Class<T> targetClass)
    • apply

      <T, U> ValidationContext apply(ValidationFunction.TypedArg<T,U> validator, Class<T> targetClass, U arg)
    • apply

    • apply

      <T> ValidationContext apply(ValidationFunction.Version<T> validator, Class<T> targetClass)
    • applyIf

      ValidationContext applyIf(boolean condition, ValidationFunction.Basic validator)
    • applyIf

      ValidationContext applyIf(boolean condition, ValidationFunction.Typed<String> validator)
    • applyIf

      <T> ValidationContext applyIf(boolean condition, ValidationFunction.Typed<T> validator, Class<T> targetClass)
    • applyIf

      <T, U> ValidationContext applyIf(boolean condition, ValidationFunction.TypedArg<T,U> validator, Class<T> targetClass, U arg)
    • applyIf

      <T> ValidationContext applyIf(boolean condition, ValidationFunction.Version<T> validator, 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, Class<T> targetClass)
    • applyOneOf

      <T, U> ValidationContext applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.TypedArg<T,U> validator, Class<T> targetClass, U arg)
    • applyOneOf

      <T> ValidationContext applyOneOf(com.google.protobuf.Descriptors.FieldDescriptor field, ValidationFunction.Version<T> validator, Class<T> targetClass)
    • applyRepeated

      ValidationContext applyRepeated(ValidationFunction.Basic validator)
    • applyRepeated

    • applyRepeated

      <T> ValidationContext applyRepeated(ValidationFunction.Typed<T> validator, Class<T> targetClass)
    • applyRepeated

      <T, U> ValidationContext applyRepeated(ValidationFunction.TypedArg<T,U> validator, Class<T> targetClass, U arg)
    • applyMapKeys

    • applyMapKeys

    • applyMapKeys

      <U> ValidationContext applyMapKeys(ValidationFunction.TypedArg<String,U> validator, U arg)
    • applyMapValues

      <T> ValidationContext applyMapValues(ValidationFunction.Basic validator)
    • applyMapValues

      <T> ValidationContext applyMapValues(ValidationFunction.Typed<T> validator, Class<T> targetClass)
    • applyMapValues

      <T, U> ValidationContext applyMapValues(ValidationFunction.TypedArg<T,U> validator, Class<T> targetClass, U arg)
    • validationType

      ValidationType validationType()
    • key

    • target

      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

      String fieldName()
    • prior

    • failed

      boolean failed()
    • skipped

      boolean skipped()
    • done

      boolean done()
    • getErrors

      List<ValidationFailure> getErrors()