Interface ChunkedPacketSender.Builder

Enclosing interface:
ChunkedPacketSender

public static interface ChunkedPacketSender.Builder
A builder for a chunked packet sender, holding all general options.
Since:
4.0
  • Method Details

    • chunkSize

      @NonNull @NonNull ChunkedPacketSender.Builder chunkSize(int chunkSize)
      Sets the size each chunk has except for the last one must have. This defaults to 1 MB. The supplied value must be greater than 0.
      Parameters:
      chunkSize - the size of each transferred chunk.
      Returns:
      the same builder as used to call the method, for chaining.
    • sessionUniqueId

      Sets the unique id of the session. This defaults to a random id.
      Parameters:
      uuid - the session id to use.
      Returns:
      the same builder as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given id is null.
    • transferChannel

      Sets the name of the transfer channel. This option is required to be set by yourself. The channel role is just identification of the incoming data. There should never be two channels named the same way.
      Parameters:
      transferChannel - the transfer channel name to use.
      Returns:
      the same builder as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given channel name is null.
    • source

      Sets the source of this data transfer. This option is required to be set by yourself. The source stream should not be closed by you, it will be closed when the transfer finished successfully.
      Parameters:
      source - the data source of the transfer.
      Returns:
      the same builder as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given source is null.
    • toChannels

      Sends each chunk data packet to all the provided channels. You need to call one of these methods:
      • toChannels(NetworkChannel...)
      • toChannels(Collection)
      • packetSplitter(Consumer)
      to set the packet splitter of this sender which is required.
      Parameters:
      channels - the channels to send the packet to.
      Returns:
      the same builder as used to call the method, for chaining.
      Throws:
      NullPointerException - if one of the given channels is null.
    • toChannels

      Sends each chunk data packet to all the provided channels. You need to call one of these methods:
      • toChannels(NetworkChannel...)
      • toChannels(Collection)
      • packetSplitter(Consumer)
      to set the packet splitter of this sender which is required.
      Parameters:
      channels - the channels to send the packet to.
      Returns:
      the same builder as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given channel collection is null.
    • packetSplitter

      Sets the handler and processor of each packet which will be sent during the chunked data transfer. You need to call one of these methods:
      • toChannels(NetworkChannel...)
      • toChannels(Collection)
      • packetSplitter(Consumer)
      to set the packet splitter of this sender which is required.
      Parameters:
      splitter - the custom packet splitter to use.
      Returns:
      the same builder as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given splitter is null.
    • withExtraData

      Sets the extra information provided to each target component when opening a chunked session. The data is mainly used for identifying specific parts of the transfer, for example the target file name might be a use case. This defaults to an empty buffer.
      Parameters:
      extraData - the extra data to sent initially.
      Returns:
      the same builder as used to call the method, for chaining.
      Throws:
      NullPointerException - if the data buffer is null.
    • build

      Builds the chunked packet sender based on the supplied information in this builder.
      Returns:
      the instance build from the information.
      Throws:
      NullPointerException - if no source, splitter or channel were given.
      IllegalArgumentException - if the chunk size is not greater than 0.