Class ResourceResponse.Builder
java.lang.Object
com.thecsdev.common.resource.ResourceResponse.Builder
- Enclosing class:
ResourceResponse
A builder class for constructing instances of
ResourceResponse.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal @NotNull ResourceResponse.BuilderAdds a metadata entry to thisResourceMessage.final ResourceResponse.BuilderAdds multiple metadata values for the specified metadata name from aJsonArray.final ResourceResponse.BuilderaddAll(@NotNull String metadataName, @NotNull Collection<String> metadataValues) Adds multiple metadata values for the specified metadata name.build()Builds and returns a newResourceResponseinstance based on the configured properties.final @NotNull URIgetUri()Returns theURIthisResourceMessage.AbstractBuilderis for.final @NotNull ResourceResponse.BuilderSets a metadata entry for thisResourceMessage, replacing any existing values associated with the specified metadata name.final ResourceResponse.BuildersetData(byte @NotNull [] data) Sets the raw byte data for the resource response.final ResourceResponse.BuildersetStatus(int status) Sets the status code for thisResourceResponse.
-
Field Details
-
uri
-
metadata
-
data
protected byte[] data
-
-
Constructor Details
-
Builder
- Throws:
NullPointerException
-
Builder
- Throws:
NullPointerException
-
-
Method Details
-
setStatus
Sets the status code for thisResourceResponse.- Parameters:
status- The status code to set.- Returns:
- The current
ResourceResponse.Builderinstance for method chaining. - Throws:
IllegalStateException- If thisResourceResponse.Builderalready built aResourceResponse.
-
add
@NotNull public final @NotNull ResourceResponse.Builder add(@NotNull @NotNull String metadataName, @NotNull @NotNull String metadataValue) throws NullPointerException, IllegalStateException Adds a metadata entry to thisResourceMessage.- Parameters:
metadataName- The name of the metadata entry.metadataValue- The value of the metadata entry.- Returns:
- The current
ResourceMessage.AbstractBuilderinstance for method chaining. - Throws:
NullPointerException- If any argument isnull.IllegalStateException- If thisResourceMessage.AbstractBuilderalready built aResourceMessage.
-
addAll
public final ResourceResponse.Builder addAll(@NotNull @NotNull String metadataName, @NotNull @NotNull Collection<String> metadataValues) throws NullPointerException, IllegalStateException Adds multiple metadata values for the specified metadata name.- Parameters:
metadataName- The name of the metadata entry.metadataValues- A collection of metadata values to add.- Returns:
- The current
ResourceMessage.AbstractBuilderinstance for method chaining. - Throws:
NullPointerException- If any argument isnull.IllegalStateException- If thisResourceMessage.AbstractBuilderalready built aResourceMessage.
-
addAll
public final ResourceResponse.Builder addAll(@NotNull @NotNull String metadataName, @NotNull @NotNull com.google.gson.JsonArray metadataValues) throws NullPointerException, IllegalStateException Adds multiple metadata values for the specified metadata name from aJsonArray.- Parameters:
metadataName- The name of the metadata entry.metadataValues- AJsonArraycontaining metadata values to add.- Returns:
- The current
ResourceMessage.AbstractBuilderinstance for method chaining. - Throws:
NullPointerException- If any argument isnull.IllegalStateException- If thisResourceMessage.AbstractBuilderalready built aResourceMessage.
-
set
@NotNull public final @NotNull ResourceResponse.Builder set(@NotNull @NotNull String metadataName, @NotNull @NotNull String metadataValue) throws NullPointerException, IllegalStateException Sets a metadata entry for thisResourceMessage, replacing any existing values associated with the specified metadata name.- Parameters:
metadataName- The name of the metadata entry.metadataValue- The value of the metadata entry.- Returns:
- The current
ResourceMessage.AbstractBuilderinstance for method chaining. - Throws:
NullPointerException- If any argument isnull.IllegalStateException- If thisResourceMessage.AbstractBuilderalready built aResourceMessage.
-
setData
public final ResourceResponse.Builder setData(byte @NotNull [] data) throws NullPointerException, IllegalStateException Sets the raw byte data for the resource response.- Parameters:
data- A byte array containing the resource data.- Returns:
- The current
ResourceMessage.AbstractBuilderinstance for method chaining. - Throws:
NullPointerException- If the argument isnull.IllegalStateException- If thisResourceMessage.AbstractBuilderalready built aResourceMessage.
-
build
Builds and returns a newResourceResponseinstance based on the configured properties.- Returns:
- A new
ResourceResponseinstance.
-
getUri
-