Class ListCodec<A>

java.lang.Object
com.mojang.serialization.codecs.ListCodec<A>
All Implemented Interfaces:
Codec<List<A>>, Decoder<List<A>>, Encoder<List<A>>

public final class ListCodec<A> extends Object implements Codec<List<A>>
  • Constructor Details

    • ListCodec

      public ListCodec(Codec<A> elementCodec)
  • Method Details

    • encode

      public <T> DataResult<T> encode(List<A> input, DynamicOps<T> ops, T prefix)
      Description copied from interface: Encoder
      Encodes an object to a serialized form, adding to an existing prefix.
      Specified by:
      encode in interface Encoder<A>
      Type Parameters:
      T - the type to serialize to
      Parameters:
      input - the object to encode
      ops - a DynamicOps for the target serialized format
      prefix - existing data that the encoded object should be added to
      Returns:
      a DataResult containing the serialized form of the object, or an error if the object could not be serialized
    • decode

      public <T> DataResult<Pair<List<A>,T>> decode(DynamicOps<T> ops, T input)
      Description copied from interface: Decoder
      Decodes an object from a serialized form, returning any remaining serialized data.
      Specified by:
      decode in interface Decoder<A>
      Type Parameters:
      T - the type of the serialized form
      Parameters:
      ops - a DynamicOps for the serialized form
      input - the serialized form to decode
      Returns:
      a DataResult containing the decoded object and any remaining serialized data, or an error if the object could not be decoded
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object