Interface ValidationContext

    • 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 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​(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
      • 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()
      • failed

        boolean failed()
      • skipped

        boolean skipped()
      • done

        boolean done()