Class ResteasyEntityPartBuilder
- All Implemented Interfaces:
EntityPart.Builder
EntityPart.Builder.
This is not intended for direct usage. Use the EntityPart.withName(String) instead.
- Author:
- James R. Perkins
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new builder with the part name. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a new EntityPart instance using the provided property values.content(InputStream content) Sets the content for this part.Sets the content for this part.content(T content, GenericType<T> type) Sets the content for this part.Sets the content for this part.Sets the file name for this part.Adds a new header or replaces a previously added header and sets the header value(s).headers(MultivaluedMap<String, String> newHeaders) Adds new headers or replaces previously added headers.Sets the media type for the EntityPart.Convenience method for setting the media type for the EntityPart.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.ws.rs.core.EntityPart.Builder
content
-
Constructor Details
-
ResteasyEntityPartBuilder
Creates a new builder with the part name.- Parameters:
name- the part name
-
-
Method Details
-
mediaType
Description copied from interface:EntityPart.BuilderSets the media type for the EntityPart. This will also set theContent-Typeheader for this part.- Specified by:
mediaTypein interfaceEntityPart.Builder- Parameters:
mediaType- the media type for the part to be built- Returns:
- the updated builder
- Throws:
IllegalArgumentException- ifmediaTypeisnull
-
mediaType
Description copied from interface:EntityPart.BuilderConvenience method for setting the media type for the EntityPart. This will also set theContent-Typeheader for this part. This call is effectively the same asmediaType(MediaType.valueOf(mediaTypeString)).- Specified by:
mediaTypein interfaceEntityPart.Builder- Parameters:
mediaTypeString- the media type for the part to be built- Returns:
- the updated builder
- Throws:
IllegalArgumentException- ifmediaTypeStringcannot be parsed or isnull
-
header
public EntityPart.Builder header(String headerName, String... headerValues) throws IllegalArgumentException Description copied from interface:EntityPart.BuilderAdds a new header or replaces a previously added header and sets the header value(s).- Specified by:
headerin interfaceEntityPart.Builder- Parameters:
headerName- the header nameheaderValues- the header value(s)- Returns:
- the updated builder
- Throws:
IllegalArgumentException- ifheaderNameisnull
-
headers
public EntityPart.Builder headers(MultivaluedMap<String, String> newHeaders) throws IllegalArgumentExceptionDescription copied from interface:EntityPart.BuilderAdds new headers or replaces previously added headers. The behavior of this method would be the same as if iterating over the entry set and invoking theEntityPart.Builder.header(String, String...)method.- Specified by:
headersin interfaceEntityPart.Builder- Parameters:
newHeaders- the multivalued map of headers to add to this part- Returns:
- the updated builder
- Throws:
IllegalArgumentException- ifnewHeadersisnull
-
fileName
Description copied from interface:EntityPart.BuilderSets the file name for this part. The file name will be specified as an attribute in theContent-Dispositionheader of this part. When this method is called, the default media type used for the built part will be "application/octet-stream" if not otherwise specified.- Specified by:
fileNamein interfaceEntityPart.Builder- Parameters:
fileName- the file name for this part- Returns:
- the updated builder
- Throws:
IllegalArgumentException- iffileNameisnull
-
content
Description copied from interface:EntityPart.BuilderSets the content for this part. The content of this builder must be specified before invoking theEntityPart.Builder.build()method.The
InputStreamwill be closed by the implementation code after sending the multipart data. Closing the stream before it is sent could result in unexpected behavior.- Specified by:
contentin interfaceEntityPart.Builder- Parameters:
content-InputStreamof the content of this part- Returns:
- the updated builder
- Throws:
IllegalArgumentException- ifcontentisnull
-
content
public <T> EntityPart.Builder content(T content, Class<? extends T> type) throws IllegalArgumentException Description copied from interface:EntityPart.BuilderSets the content for this part. The content of this builder must be specified before invoking theEntityPart.Builder.build()method.If the content is specified using this method, then the
EntityPart.Builder.build()method is responsible for finding a registeredMessageBodyWriterthat is capable of writing the object type specified here using the defaultMediaTypeor theMediaTypespecified in theEntityPart.Builder.mediaType(MediaType)orEntityPart.Builder.mediaType(String)methods and using any headers specified via theEntityPart.Builder.header(String, String...)orEntityPart.Builder.headers(MultivaluedMap)methods.- Specified by:
contentin interfaceEntityPart.Builder- Type Parameters:
T- the entity type- Parameters:
content- the object to be used as the contenttype- the type of this object which will be used when selecting the appropriateMessageBodyWriter- Returns:
- the updated builder.
- Throws:
IllegalArgumentException- ifcontentisnull
-
content
Description copied from interface:EntityPart.BuilderSets the content for this part. The content of this builder must be specified before invoking theEntityPart.Builder.build()method.If the content is specified using this method, then the
EntityPart.Builder.build()method is responsible for finding a registeredMessageBodyWriterthat is capable of writing the object's class type specified here using the defaultMediaTypeor theMediaTypespecified in theEntityPart.Builder.mediaType(MediaType)orEntityPart.Builder.mediaType(String)methods and using any headers specified via theEntityPart.Builder.header(String, String...)orEntityPart.Builder.headers(MultivaluedMap)methods.This is the equivalent of calling
content(content, content.getClass()).- Specified by:
contentin interfaceEntityPart.Builder- Parameters:
content- the object to be used as the content- Returns:
- the updated builder.
- Throws:
IllegalArgumentException- ifcontentisnull
-
content
public <T> EntityPart.Builder content(T content, GenericType<T> type) throws IllegalArgumentException Description copied from interface:EntityPart.BuilderSets the content for this part. The content of this builder must be specified before invoking theEntityPart.Builder.build()method.If the content is specified using this method, then the
EntityPart.Builder.build()method is responsible for finding a registeredMessageBodyWriterthat is capable of writing the object type specified here using the defaultMediaTypeor theMediaTypespecified in theEntityPart.Builder.mediaType(MediaType)orEntityPart.Builder.mediaType(String)methods and using any headers specified via theEntityPart.Builder.header(String, String...)orEntityPart.Builder.headers(MultivaluedMap)methods.- Specified by:
contentin interfaceEntityPart.Builder- Type Parameters:
T- the entity type- Parameters:
content- the object to be used as the contenttype- the generic type of this object which will be used when selecting the appropriateMessageBodyWriter- Returns:
- the updated builder.
- Throws:
IllegalArgumentException- ifcontentisnull
-
build
Description copied from interface:EntityPart.BuilderBuilds a new EntityPart instance using the provided property values.- Specified by:
buildin interfaceEntityPart.Builder- Returns:
EntityPartinstance built from the provided property values.- Throws:
IllegalStateException- if the content was not specified or no matchingMessageBodyWriterwas found.IOException- if the underlyingMessageBodyWriterthrows anIOExceptionWebApplicationException- if the underlyingMessageBodyWriterthrows aWebApplicationException
-