Record Class DataTypeBuilderStreamCodec<C>

java.lang.Object
java.lang.Record
dev.latvian.mods.klib.data.DataTypeBuilderStreamCodec<C>
All Implemented Interfaces:
KLibStreamCodec<io.netty.buffer.ByteBuf,C>, net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,C>, net.minecraft.network.codec.StreamDecoder<io.netty.buffer.ByteBuf,C>, net.minecraft.network.codec.StreamEncoder<io.netty.buffer.ByteBuf,C>

public record DataTypeBuilderStreamCodec<C>(List<DataTypeField<C,?>> fields, Function<Object[],C> constructor, boolean canBeOptional) extends Record implements net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,C>
  • Constructor Details

    • DataTypeBuilderStreamCodec

      public DataTypeBuilderStreamCodec(List<DataTypeField<C,?>> fields, Function<Object[],C> constructor)
    • DataTypeBuilderStreamCodec

      public DataTypeBuilderStreamCodec(List<DataTypeField<C,?>> fields, Function<Object[],C> constructor, boolean canBeOptional)
      Creates an instance of a DataTypeBuilderStreamCodec record class.
      Parameters:
      fields - the value for the fields record component
      constructor - the value for the constructor record component
      canBeOptional - the value for the canBeOptional record component
  • Method Details

    • decode

      public C decode(io.netty.buffer.ByteBuf buf)
      Specified by:
      decode in interface net.minecraft.network.codec.StreamDecoder<io.netty.buffer.ByteBuf,C>
    • encode

      public void encode(io.netty.buffer.ByteBuf buf, C value)
      Specified by:
      encode in interface net.minecraft.network.codec.StreamEncoder<io.netty.buffer.ByteBuf,C>
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • fields

      public List<DataTypeField<C,?>> fields()
      Returns the value of the fields record component.
      Returns:
      the value of the fields record component
    • constructor

      public Function<Object[],C> constructor()
      Returns the value of the constructor record component.
      Returns:
      the value of the constructor record component
    • canBeOptional

      public boolean canBeOptional()
      Returns the value of the canBeOptional record component.
      Returns:
      the value of the canBeOptional record component