Class JsonMissingFieldException.Builder

All Implemented Interfaces:
JsonExceptionBuilder<JsonMissingFieldException>
Enclosing class:
JsonMissingFieldException

@NotThreadSafe public static final class JsonMissingFieldException.Builder extends AbstractJsonExceptionBuilder<JsonMissingFieldException>
A mutable builder for a JsonMissingFieldException.
  • Method Details

    • fieldName

      public JsonMissingFieldException.Builder fieldName(CharSequence missingFieldName)
      Sets a message which points to the name of the missing field. Thus if this method is called, AbstractJsonExceptionBuilder.message should not be called.
      Parameters:
      missingFieldName - the name of the missing field.
      Returns:
      this builder to allow method chaining.
    • fieldName

      public JsonMissingFieldException.Builder fieldName(CharSequence missingFieldNameRoot, CharSequence... missingFieldNameChildren)
      Sets a message which points to the name of the missing field within a hierarchy.

      Given the following valid JSON object:

          {
             "attributes": {
                "localSeason": {
                   "season": "autumn",
                   "location": {
                      "country": "Germany",
                      "state": "Baden-Wuerttemberg",
                      "place": "Leimerstetten"
                   }
                }
             }
          }
       

      If, for example, the field state is missing the call to this method would be fieldName("attributes", "localSeason", "location", "state").

      Parameters:
      missingFieldNameRoot - the root of the hierarchy.
      missingFieldNameChildren - all children, grand children etc. of missingFieldNameRoot.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if any argument is null.
      See Also:
    • doBuild

      protected JsonMissingFieldException doBuild(String errorCode, @Nullable String message, @Nullable String description, @Nullable Throwable cause, @Nullable URI href)
      Description copied from class: AbstractJsonExceptionBuilder
      This method must be implemented by subclasses. It is responsible for actually building the exception object. Therefore it receives the data which was provided during the building process.
      Specified by:
      doBuild in class AbstractJsonExceptionBuilder<JsonMissingFieldException>
      Parameters:
      errorCode - the error code.
      message - the detail message or null.
      description - the description or null.
      cause - the cause or null.
      href - the link to further information or null.
      Returns:
      a new exception of the target type.