Interface DuplicateFieldError

All Superinterfaces:
ErrorObject

public interface DuplicateFieldError extends ErrorObject

Returned when a field value conflicts with an existing value causing a duplicate.


Example to create an instance using the builder pattern

     DuplicateFieldError duplicateFieldError = DuplicateFieldError.builder()
             .message("{message}")
             .field("{field}")
             .build()
 
  • Field Details

  • Method Details

    • getCode

      @NotNull @NotNull String getCode()
      Description copied from interface: ErrorObject

      Error identifier.

      Specified by:
      getCode in interface ErrorObject
      Returns:
      code
    • getMessage

      @NotNull @NotNull String getMessage()

      "A duplicate value $duplicateValue exists for field $field."

      Specified by:
      getMessage in interface ErrorObject
      Returns:
      message
    • getField

      @NotNull @NotNull String getField()

      Name of the conflicting field.

      Returns:
      field
    • getDuplicateValue

      @NotNull @NotNull Object getDuplicateValue()

      Conflicting duplicate value.

      Returns:
      duplicateValue
    • setMessage

      void setMessage(String message)

      "A duplicate value $duplicateValue exists for field $field."

      Specified by:
      setMessage in interface ErrorObject
      Parameters:
      message - value to be set
    • setField

      void setField(String field)

      Name of the conflicting field.

      Parameters:
      field - value to be set
    • setDuplicateValue

      void setDuplicateValue(Object duplicateValue)

      Conflicting duplicate value.

      Parameters:
      duplicateValue - value to be set
    • of

      static DuplicateFieldError of()
      factory method
      Returns:
      instance of DuplicateFieldError
    • of

      factory method to create a shallow copy DuplicateFieldError
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • deepCopy

      factory method to create a deep copy of DuplicateFieldError
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • builder

      static DuplicateFieldErrorBuilder builder()
      builder factory method for DuplicateFieldError
      Returns:
      builder
    • builder

      create builder for DuplicateFieldError instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder
    • withDuplicateFieldError

      default <T> T withDuplicateFieldError(Function<DuplicateFieldError,T> helper)
      accessor map function
      Type Parameters:
      T - mapped type
      Parameters:
      helper - function to map the object
      Returns:
      mapped value
    • typeReference

      static com.fasterxml.jackson.core.type.TypeReference<DuplicateFieldError> typeReference()
      gives a TypeReference for usage with Jackson DataBind
      Returns:
      TypeReference