Class ImmediateSingleObjectBody

java.lang.Object
io.micronaut.http.server.netty.body.ImmediateSingleObjectBody
All Implemented Interfaces:
HttpBody, MultiObjectBody

@Internal public final class ImmediateSingleObjectBody extends Object implements HttpBody, MultiObjectBody
HttpBody that contains a single object. This is used to implement NettyHttpRequest.getBody() and CompletableFuture binding.
Since:
4.0.0
Author:
Jonas Konrad
  • Method Details

    • claimForExternal

      public Object claimForExternal()
      Get the value and transfer ownership to the caller. The caller must release the value after it's done. Can only be called once.
      Returns:
      The claimed value
    • valueUnclaimed

      public Object valueUnclaimed()
      Get the value without transferring ownership. The returned value may become invalid when other code calls claimForExternal() or when the netty request is destroyed.
      Returns:
      The unclaimed value
    • convert

      public Optional<ImmediateSingleObjectBody> convert(ConversionService conversionService, ArgumentConversionContext<?> context)
    • coerceToInputStream

      public InputStream coerceToInputStream(io.netty.buffer.ByteBufAllocator alloc)
      Description copied from interface: MultiObjectBody
      Coerce this value to an InputStream. This implements io.micronaut.http.server.netty.binders.InputStreamBodyBinder. Requires the objects of this body to be ByteBufs.
      Ownership is transferred to the stream, it must be closed to release all buffers.
      Specified by:
      coerceToInputStream in interface MultiObjectBody
      Parameters:
      alloc - The buffer allocator to use
      Returns:
      The stream that reads the data in this body
    • asPublisher

      public Publisher<?> asPublisher()
      Description copied from interface: MultiObjectBody
      Get this value as a publisher. The publisher must be subscribed to exactly once. All objects forwarded to the subscriber become its responsibility and must be released by the subscriber.
      Specified by:
      asPublisher in interface MultiObjectBody
      Returns:
      The publisher
    • mapNotNull

      public MultiObjectBody mapNotNull(Function<Object,Object> transform)
      Description copied from interface: MultiObjectBody
      Apply a mapping function to all objects in this body. null values in the output are skipped.
      Specified by:
      mapNotNull in interface MultiObjectBody
      Parameters:
      transform - The mapping function
      Returns:
      A new body with the mapped values
    • handleForm

      public void handleForm(FormRouteCompleter formRouteCompleter)
      Description copied from interface: MultiObjectBody
      Special handling for form data. This method basically acts like asPublisher().subscribe(formRouteCompleter). However, FormRouteCompleter needs to release the form data fields when the request is destroyed. To do this, it implements HttpBody.release(). By calling this method, the FormRouteCompleter is registered as the next body and will be released.
      Specified by:
      handleForm in interface MultiObjectBody
      Parameters:
      formRouteCompleter - The form route completer that should take over processing
    • release

      public final void release()
      Description copied from interface: HttpBody
      Release this body and any downstream representations.
      Specified by:
      release in interface HttpBody
    • next

      @Nullable public @Nullable HttpBody next()
      Description copied from interface: HttpBody
      Get the next representation this body was transformed into, if any.
      Specified by:
      next in interface HttpBody
      Returns:
      The next representation, or null if this body has not been transformed