Class EitherCodec<F,S>

java.lang.Object
com.mojang.serialization.codecs.EitherCodec<F,S>
All Implemented Interfaces:
Codec<Either<F,S>>, Decoder<Either<F,S>>, Encoder<Either<F,S>>

public final class EitherCodec<F,S> extends Object implements Codec<Either<F,S>>
  • Constructor Details

    • EitherCodec

      public EitherCodec(Codec<F> first, Codec<S> second)
  • Method Details

    • decode

      public <T> DataResult<Pair<Either<F,S>,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<F>
      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
    • encode

      public <T> DataResult<T> encode(Either<F,S> 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<F>
      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
    • 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