Module methanol

Class TaggableRequest

  • Direct Known Subclasses:
    MutableRequest

    public abstract class TaggableRequest
    extends java.net.http.HttpRequest
    An HttpRequest that can carry arbitrary values, referred to as tags. Tags can be used to carry application-specific data throughout interceptors and listeners. Tags are mapped by their type. One type cannot map to more than one tag.

    A TaggableRequest also carries the BodyAdapter.Hints to be used when encoding the request body and/or decoding the response body. Hints are like tags but are meant to carry arbitrary values to adapters rather than interceptors or listeners.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  TaggableRequest.Builder
      An HttpRequest.Builder that allows attaching tags.
      • Nested classes/interfaces inherited from class java.net.http.HttpRequest

        java.net.http.HttpRequest.BodyPublisher, java.net.http.HttpRequest.BodyPublishers
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static TaggableRequest from​(java.net.http.HttpRequest request)
      Returns either the given request if it's a TaggableRequest or a new TaggableRequest copy with no tags otherwise.
      abstract BodyAdapter.Hints hints()
      Returns this request's BodyAdapter.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 a TaggableRequest and it has a tag with the given type, otherwise returns an empty Optional.
      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 a TaggableRequest and it has a tag with the given type, otherwise returns an empty Optional.
      • Methods inherited from class java.net.http.HttpRequest

        bodyPublisher, equals, expectContinue, hashCode, headers, method, newBuilder, newBuilder, timeout, uri, version
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • 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.
      • from

        public static TaggableRequest from​(java.net.http.HttpRequest request)
        Returns either the given request if it's a TaggableRequest or a new TaggableRequest copy 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 a TaggableRequest and it has a tag with the given type, otherwise returns an empty Optional.
      • 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 a TaggableRequest and it has a tag with the given type, otherwise returns an empty Optional.