@NotThreadSafe public static final class ResponseStatus.Builder extends AbstractResponseStatus.AbstractBuilder<ResponseStatus.Builder,ResponseStatus>
Builder pattern for the ResponseStatus
class.
Effective Java, 2nd Ed. : Item 2: Builder Pattern.
This Builder is not thread-safe but is thread-compliant, it is supposed to be used by only one thread.
Constructor and Description |
---|
Builder() |
Builder(IResponseStatus copy) |
Builder(ResponseStatus.Builder copy) |
Modifier and Type | Method and Description |
---|---|
protected ResponseStatus |
newInstance()
Method to be implemented by subtypes to create the right type
T of instances. |
protected void |
validate()
Validates the state of this Builder before allowing to create new instances of the built type
T . |
build, failure, statusCode, statusMessage, subStatusCode
public Builder()
public Builder(@Nonnull ResponseStatus.Builder copy)
public Builder(@Nonnull IResponseStatus copy)
protected void validate() throws IllegalArgumentException
AbstractResponseStatus.AbstractBuilder
T
.validate
in class AbstractResponseStatus.AbstractBuilder<ResponseStatus.Builder,ResponseStatus>
IllegalArgumentException
- if the builder is not in a legal state allowing to proceed with the creation
of a T
instance.@Nonnull protected ResponseStatus newInstance()
AbstractResponseStatus.AbstractBuilder
Method to be implemented by subtypes to create the right type T
of instances.
The typical implementation simply consists in writing return new MySubType(this);
newInstance
in class AbstractResponseStatus.AbstractBuilder<ResponseStatus.Builder,ResponseStatus>
T
instance based on this Builder instance.Copyright © 2020. All Rights Reserved.