Class ResourceRequest.Builder
java.lang.Object
com.thecsdev.common.resource.ResourceRequest.Builder
- Enclosing class:
ResourceRequest
A builder for creating instances of
ResourceRequest.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal @NotNull ResourceRequest.BuilderAdds a metadata entry to thisResourceMessage.final ResourceRequest.BuilderAdds multiple metadata values for the specified metadata name from aJsonArray.final ResourceRequest.BuilderaddAll(@NotNull String metadataName, @NotNull Collection<String> metadataValues) Adds multiple metadata values for the specified metadata name.final @NotNull ResourceRequestbuild()Builds and returns a newResourceRequestinstance based on the current state of the builder.final @NotNull URIgetUri()Returns theURIthisResourceMessage.AbstractBuilderis for.final @NotNull ResourceRequest.BuilderSets a metadata entry for thisResourceMessage, replacing any existing values associated with the specified metadata name.final ResourceRequest.BuildersetData(byte @NotNull [] data) Sets the raw byte data for the resource response.
-
Field Details
-
uri
-
metadata
-
data
protected byte[] data
-
-
Constructor Details
-
Builder
- Throws:
NullPointerException
-
-
Method Details
-
add
@NotNull public final @NotNull ResourceRequest.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 ResourceRequest.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 ResourceRequest.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 ResourceRequest.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 ResourceRequest.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 newResourceRequestinstance based on the current state of the builder.- Returns:
- A new
ResourceRequestinstance.
-
getUri
-