Enum Chunking.RemainderPolicy

java.lang.Object
java.lang.Enum<Chunking.RemainderPolicy>
dev.zachmaddox.chunking.Chunking.RemainderPolicy
All Implemented Interfaces:
Serializable, Comparable<Chunking.RemainderPolicy>
Enclosing class:
Chunking

public static enum Chunking.RemainderPolicy extends Enum<Chunking.RemainderPolicy>
Defines how to handle the trailing remainder when the input size is not evenly divisible by the chunk size.
  • Enum Constant Details

    • INCLUDE_PARTIAL

      public static final Chunking.RemainderPolicy INCLUDE_PARTIAL
      Include the final partial chunk (default behavior).
    • DROP_PARTIAL

      public static final Chunking.RemainderPolicy DROP_PARTIAL
      Drop the final chunk if it is smaller than chunkSize.
    • PAD_WITH_NULLS

      public static final Chunking.RemainderPolicy PAD_WITH_NULLS
      Pad the final chunk with null values until it reaches chunkSize.

      This is primarily useful when consumers require every chunk to have a uniform size and can safely handle null values inside the chunk. For primitive streams, this policy applies after boxing (for example, IntStream becomes Stream<Integer>).

    • ERROR_IF_PARTIAL

      public static final Chunking.RemainderPolicy ERROR_IF_PARTIAL
      Fail fast if the input size is not evenly divisible by chunkSize.

      An IllegalStateException is thrown if a trailing partial chunk would be required.

  • Method Details

    • values

      public static Chunking.RemainderPolicy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static Chunking.RemainderPolicy valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null