Interface ResourceWriter

All Known Implementing Classes:
AbstractResourceWriter, FileResourceWriter
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ResourceWriter
Interface (contract) for writers to define the algorithm or strategy for writing data to a target Resource, such as by using the WritableResource's WritableResource.getOutputStream() OutputStream}.
Since:
1.3.1
See Also:
  • Resource
  • WritableResource
  • Method Summary

    Modifier and Type
    Method
    Description
    Composes this ResourceWriter with the given ResourceWriter using the Composite Software Design Pattern.
    void
    write(org.springframework.core.io.Resource resource, byte[] data)
    Writes data to the target Resource as defined by the algorithm/strategy of this writer.
    default void
    write(org.springframework.core.io.Resource resource, ByteBuffer data)
    Writes data contained in the ByteBuffer to the target Resource as defined by the algorithm/strategy of this writer.
  • Method Details

    • write

      void write(@NonNull org.springframework.core.io.Resource resource, byte[] data)
      Writes data to the target Resource as defined by the algorithm/strategy of this writer. This method should throw an UnhandledResourceException if the algorithm or strategy used by this writer is not able to or capable of writing to the Resource at its location. This allows subsequent writers in a composition to possibly handle the Resource. Any other Exception thrown by this write method will break the chain of write calls in the composition.
      Parameters:
      resource - Resource to write data to.
      data - array of bytes containing the data to write to the target Resource.
      See Also:
      • Resource
    • write

      default void write(@NonNull org.springframework.core.io.Resource resource, ByteBuffer data)
      Writes data contained in the ByteBuffer to the target Resource as defined by the algorithm/strategy of this writer. This method should throw an UnhandledResourceException if the algorithm or strategy used by this writer is not able to or capable of writing to the Resource at its location. This allows subsequent writers in a composition to possibly handle the Resource. Any other Exception thrown by this write method will break the chain of write calls in the composition.
      Parameters:
      resource - Resource to write data to.
      data - ByteBuffer containing the data to write to the target Resource.
      See Also:
    • thenWriteTo

      default ResourceWriter thenWriteTo(ResourceWriter writer)
      Composes this ResourceWriter with the given ResourceWriter using the Composite Software Design Pattern.
      Parameters:
      writer - ResourceWriter to compose with this writer.
      Returns:
      a composite ResourceWriter composed of this ResourceWriter and the given ResourceWriter. If the given ResourceWriter is null, then this ResourceWriter is returned.
      See Also: