- java.lang.Object
-
- java.net.http.HttpRequest
-
- com.github.mizosoft.methanol.TaggableRequest
-
- Direct Known Subclasses:
MutableRequest
public abstract class TaggableRequest extends java.net.http.HttpRequestAnHttpRequestthat can carry arbitrary values, referred to as tags. Tags can be used to carry application-specific data throughoutinterceptorsand listeners. Tags are mapped by their type. One type cannot map to more than one tag.A
TaggableRequestalso carries theBodyAdapter.Hintsto be used when encoding the request body and/or decoding the response body. Hints are like tags but are meant to carry arbitrary values toadaptersrather than interceptors or listeners.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTaggableRequest.BuilderAnHttpRequest.Builderthat allows attaching tags.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static TaggableRequestfrom(java.net.http.HttpRequest request)Returns either the given request if it's aTaggableRequestor a newTaggableRequestcopy with no tags otherwise.abstract BodyAdapter.Hintshints()Returns this request'sBodyAdapter.Hints.<T> java.util.Optional<T>tag(TypeRef<T> typeRef)Returns the tag associated with the given type if present.<T> java.util.Optional<T>tag(java.lang.Class<T> type)Returns the tag associated with the given type if present.static <T> java.util.Optional<T>tagOf(java.net.http.HttpRequest request, TypeRef<T> typeRef)Returns the tag associated with the given type if the given request is aTaggableRequestand it has a tag with the given type, otherwise returns an emptyOptional.static <T> java.util.Optional<T>tagOf(java.net.http.HttpRequest request, java.lang.Class<T> type)Returns the tag associated with the given type if the given request is aTaggableRequestand it has a tag with the given type, otherwise returns an emptyOptional.
-
-
-
Method Detail
-
tag
public <T> java.util.Optional<T> tag(java.lang.Class<T> type)
Returns the tag associated with the given type if present.
-
tag
public <T> java.util.Optional<T> tag(TypeRef<T> typeRef)
Returns the tag associated with the given type if present.
-
hints
public abstract BodyAdapter.Hints hints()
Returns this request'sBodyAdapter.Hints.
-
from
public static TaggableRequest from(java.net.http.HttpRequest request)
Returns either the given request if it's aTaggableRequestor a newTaggableRequestcopy with no tags otherwise.
-
tagOf
public static <T> java.util.Optional<T> tagOf(java.net.http.HttpRequest request, java.lang.Class<T> type)Returns the tag associated with the given type if the given request is aTaggableRequestand it has a tag with the given type, otherwise returns an emptyOptional.
-
tagOf
public static <T> java.util.Optional<T> tagOf(java.net.http.HttpRequest request, TypeRef<T> typeRef)Returns the tag associated with the given type if the given request is aTaggableRequestand it has a tag with the given type, otherwise returns an emptyOptional.
-
-