Record Class CodecGrouper1<CI1,O>

java.lang.Object
java.lang.Record
net.luis.utils.io.codec.group.grouper.CodecGrouper1<CI1,O>
Type Parameters:
CI1 - The type of the first component
O - The type of the resulting object this grouper is for
Record Components:
codec1 - The first codec

public record CodecGrouper1<CI1,O>(@NotNull ConfiguredCodec<CI1,O> codec1) extends Record
Represents a group of one codec.
The grouper is used for creating a new single codec that encodes and decodes a value of a specific type.
Each codec is responsible for encoding and decoding a specific component (field) of the value.
The grouped codec is created by providing a function that creates the value from the decoded components.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final @NotNull ConfiguredCodec<CI1,O>
    The field for the codec1 record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CodecGrouper1(@NotNull ConfiguredCodec<CI1,O> codec1)
    Constructs a new codec grouper with the provided codec.
    Do not use this constructor directly, use the builder method in CodecBuilder instead.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the codec1 record component.
    @NotNull Codec<O>
    create(@NotNull CodecGroupingFunction1<CI1,O> function)
    Creates a new codec using the codecs of this grouper and the provided grouping function.
    The grouping function is used to create the resulting object from the decoded components.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • CodecGrouper1

      @Internal public CodecGrouper1(@NotNull @NotNull ConfiguredCodec<CI1,O> codec1)
      Constructs a new codec grouper with the provided codec.
      Do not use this constructor directly, use the builder method in CodecBuilder instead.
      Parameters:
      codec1 - The codec
      Throws:
      NullPointerException - If any of the provided codecs is null
  • Method Details

    • create

      @NotNull public @NotNull Codec<O> create(@NotNull @NotNull CodecGroupingFunction1<CI1,O> function)
      Creates a new codec using the codecs of this grouper and the provided grouping function.
      The grouping function is used to create the resulting object from the decoded components.
      Parameters:
      function - The grouping function
      Returns:
      The created codec
      Throws:
      NullPointerException - If the provided grouping function is null
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • codec1

      @NotNull public @NotNull ConfiguredCodec<CI1,O> codec1()
      Returns the value of the codec1 record component.
      Returns:
      the value of the codec1 record component