Package org.eclipse.ditto.json
Class AbstractJsonExceptionBuilder<T extends JsonException>
java.lang.Object
org.eclipse.ditto.json.AbstractJsonExceptionBuilder<T>
- Type Parameters:
T
- type of the subclass ofJsonRuntimeException
.
- All Implemented Interfaces:
JsonExceptionBuilder<T>
- Direct Known Subclasses:
JsonFieldSelectorInvalidException.Builder
,JsonKeyInvalidException.Builder
,JsonMissingFieldException.Builder
,JsonParseException.Builder
,JsonPointerInvalidException.Builder
,JsonRuntimeException.Builder
@NotThreadSafe
public abstract class AbstractJsonExceptionBuilder<T extends JsonException>
extends Object
implements JsonExceptionBuilder<T>
Abstract base implementation for builders which create objects of subtypes of
JsonRuntimeException
.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractJsonExceptionBuilder
(String errorCode) Constructs a newAbstractJsonExceptionBuilder
object. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds an instance of the target exception type using the provided data.Sets the cause which led to the exception to be built.Sets the cause which led to the exception to be built.description
(String description) Sets a description with further information about the exception to be built.description
(Supplier<String> descriptionSupplier) Sets a description with further information about the exception to be built.protected abstract T
This method must be implemented by subclasses.Sets a link to a resource which provides further information about the exception to be built.Sets a link to a resource which provides further information about the exception to be built.Sets the detail message of the exception to be built.Sets the detail message of the exception to be built.
-
Constructor Details
-
AbstractJsonExceptionBuilder
Constructs a newAbstractJsonExceptionBuilder
object.- Parameters:
errorCode
- a code which uniquely identifies the exception.- Throws:
NullPointerException
- iferrorCode
isnull
.IllegalArgumentException
- iferrorCode
is empty.
-
-
Method Details
-
message
Description copied from interface:JsonExceptionBuilder
Sets the detail message of the exception to be built.- Specified by:
message
in interfaceJsonExceptionBuilder<T extends JsonException>
- Parameters:
message
- the detail message.- Returns:
- this builder to allow method chaining.
-
message
Description copied from interface:JsonExceptionBuilder
Sets the detail message of the exception to be built.- Specified by:
message
in interfaceJsonExceptionBuilder<T extends JsonException>
- Parameters:
messageSupplier
- supplier of the message to be set.- Returns:
- this builder to allow method chaining.
-
description
Description copied from interface:JsonExceptionBuilder
Sets a description with further information about the exception to be built.- Specified by:
description
in interfaceJsonExceptionBuilder<T extends JsonException>
- Parameters:
description
- a description.- Returns:
- this builder to allow method chaining.
-
description
Description copied from interface:JsonExceptionBuilder
Sets a description with further information about the exception to be built.- Specified by:
description
in interfaceJsonExceptionBuilder<T extends JsonException>
- Parameters:
descriptionSupplier
- supplier of the description to be set.- Returns:
- this builder to allow method chaining.
-
cause
Description copied from interface:JsonExceptionBuilder
Sets the cause which led to the exception to be built.- Specified by:
cause
in interfaceJsonExceptionBuilder<T extends JsonException>
- Parameters:
cause
- the cause.- Returns:
- this builder to allow method chaining.
-
cause
Description copied from interface:JsonExceptionBuilder
Sets the cause which led to the exception to be built.- Specified by:
cause
in interfaceJsonExceptionBuilder<T extends JsonException>
- Parameters:
causeSupplier
- supplier of the cause to be set.- Returns:
- this builder to allow method chaining.
-
href
Description copied from interface:JsonExceptionBuilder
Sets a link to a resource which provides further information about the exception to be built.- Specified by:
href
in interfaceJsonExceptionBuilder<T extends JsonException>
- Parameters:
href
- a link to further information.- Returns:
- this builder to allow method chaining.
-
href
Description copied from interface:JsonExceptionBuilder
Sets a link to a resource which provides further information about the exception to be built.- Specified by:
href
in interfaceJsonExceptionBuilder<T extends JsonException>
- Parameters:
hrefSupplier
- supplier of the link to be set.- Returns:
- this builder to allow method chaining.
-
build
Description copied from interface:JsonExceptionBuilder
Builds an instance of the target exception type using the provided data.- Specified by:
build
in interfaceJsonExceptionBuilder<T extends JsonException>
- Returns:
- a new exception of the target type.
-
doBuild
protected abstract T doBuild(String errorCode, String message, String description, Throwable cause, URI href) 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.- Parameters:
errorCode
- the error code.message
- the detail message ornull
.description
- the description ornull
.cause
- the cause ornull
.href
- the link to further information ornull
.- Returns:
- a new exception of the target type.
-