-
- Enclosing interface:
- BodyAdapter
public static interface BodyAdapter.HintsA collection of hints that provide additional context to customize an adapter's encoding/decoding behavior. Typically, an adapter receives aHintsobject that contains theMediaTypeof the intended format as advertised by the request or response. Additionally, an encoder receives aHintsobjects containing therequest(), and a decoder receives one that contains theresponseInfo(). Some hints are optional, and adapters substitute with default values in the absence thereof (for instance, a JSON adapter may use UTF-8 in the absence of aMediaTypecontaining a charset parameter). If a hint is required by the adapter, it throws anUnsupportedOperationExceptionin the absence of such.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classBodyAdapter.Hints.BuilderA builder ofHintobjects.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static BodyAdapter.Hintsempty()Returns aHintsobject containing no hints.booleanequals(java.lang.Object obj)<T> java.util.Optional<T>get(java.lang.Class<T> type)Returns the hint mapped to by the given type.inthashCode()default java.util.Optional<MediaType>mediaType()Returns theMediaTypehint.default MediaTypemediaTypeOrAny()Returns either theMediaTypehint orMediaType.ANYif absent.default BodyAdapter.Hints.Buildermutate()Returns a newBuildercontaining this object's hints.static BodyAdapter.Hints.BuildernewBuilder()Returns a newBuilder.static BodyAdapter.Hintsof(MediaType mediaType)Returns aHintsobject containing the given media type.default java.util.Optional<java.net.http.HttpRequest>request()Returns theHttpRequesthint.default java.util.Optional<java.net.http.HttpResponse.ResponseInfo>responseInfo()Returns theResponseInfohint.java.util.Map<java.lang.Class<?>,java.lang.Object>toMap()Returns an immutable map of all hints.
-
-
-
Method Detail
-
toMap
java.util.Map<java.lang.Class<?>,java.lang.Object> toMap()
Returns an immutable map of all hints.
-
mediaType
default java.util.Optional<MediaType> mediaType()
Returns theMediaTypehint.
-
mediaTypeOrAny
default MediaType mediaTypeOrAny()
Returns either theMediaTypehint orMediaType.ANYif absent.
-
request
default java.util.Optional<java.net.http.HttpRequest> request()
Returns theHttpRequesthint.
-
responseInfo
default java.util.Optional<java.net.http.HttpResponse.ResponseInfo> responseInfo()
Returns theResponseInfohint.
-
get
<T> java.util.Optional<T> get(java.lang.Class<T> type)
Returns the hint mapped to by the given type.
-
mutate
default BodyAdapter.Hints.Builder mutate()
Returns a newBuildercontaining this object's hints.
-
equals
boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
newBuilder
static BodyAdapter.Hints.Builder newBuilder()
Returns a newBuilder.
-
empty
static BodyAdapter.Hints empty()
Returns aHintsobject containing no hints.
-
of
static BodyAdapter.Hints of(MediaType mediaType)
Returns aHintsobject containing the given media type.
-
-