Class BodyPublishers


  • public final class BodyPublishers
    extends java.lang.Object
    Implementations of various useful HttpRequest.BodyPublishers.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.net.http.HttpRequest.BodyPublisher ofJson​(java.lang.Object body)
      Returns a request body publisher whose body is JSON representation of body.
      static java.net.http.HttpRequest.BodyPublisher ofJson​(java.lang.Object body, JsonMappingProvider jsonProvider)
      Returns a request body publisher whose body is JSON representation of body.
      static java.net.http.HttpRequest.BodyPublisher ofJson​(java.lang.Object body, JsonMappingProvider jsonProvider, java.util.concurrent.Executor executor)
      Returns a request body publisher whose body is JSON representation of body.
      static java.net.http.HttpRequest.BodyPublisher ofJson​(java.lang.Object body, java.util.concurrent.Executor executor)
      Returns a request body publisher whose body is JSON representation of body.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • ofJson

        public static java.net.http.HttpRequest.BodyPublisher ofJson​(java.lang.Object body)
        Returns a request body publisher whose body is JSON representation of body. The conversion will be done using JsonMappingProvider default provider retrieved using JsonMappingProvider.provider().
        Parameters:
        body - The body.
        Returns:
        a BodyPublisher
      • ofJson

        public static java.net.http.HttpRequest.BodyPublisher ofJson​(java.lang.Object body,
                                                                     JsonMappingProvider jsonProvider)
        Returns a request body publisher whose body is JSON representation of body. The conversion will be done using jsonProvider.
        Parameters:
        body - The body.
        jsonProvider - The JSON mapping provider to use when creating JSON presentation of body.
        Returns:
        a BodyPublisher
      • ofJson

        public static java.net.http.HttpRequest.BodyPublisher ofJson​(java.lang.Object body,
                                                                     java.util.concurrent.Executor executor)
        Returns a request body publisher whose body is JSON representation of body. The conversion will be done using JsonMappingProvider default provider retrieved using JsonMappingProvider.provider().
        Parameters:
        body - The body.
        executor - The scheduler to use to publish body to subscriber. If null the * ForkJoinPool.commonPool() will be used.
        Returns:
        a BodyPublisher
      • ofJson

        public static java.net.http.HttpRequest.BodyPublisher ofJson​(java.lang.Object body,
                                                                     JsonMappingProvider jsonProvider,
                                                                     java.util.concurrent.Executor executor)
        Returns a request body publisher whose body is JSON representation of body. The conversion will be done * using jsonProvider.
        Parameters:
        body - The body.
        jsonProvider - The JSON mapping provider to use when creating JSON presentation of body.
        executor - The scheduler to use to publish body to subscriber. If null the ForkJoinPool.commonPool() will be used.
        Returns:
        a BodyPublisher