Class UnboundedMapCodec<K,V>

java.lang.Object
com.mojang.serialization.codecs.UnboundedMapCodec<K,V>
All Implemented Interfaces:
Codec<Map<K,V>>, BaseMapCodec<K,V>, Decoder<Map<K,V>>, Encoder<Map<K,V>>

public final class UnboundedMapCodec<K,V> extends Object implements BaseMapCodec<K,V>, Codec<Map<K,V>>
Mojang-Added Docs:

Key and value decoded independently, unknown set of keys

  • Constructor Details

    • UnboundedMapCodec

      public UnboundedMapCodec(Codec<K> keyCodec, Codec<V> elementCodec)
  • Method Details

    • keyCodec

      public Codec<K> keyCodec()
      Specified by:
      keyCodec in interface BaseMapCodec<K,V>
    • elementCodec

      public Codec<V> elementCodec()
      Specified by:
      elementCodec in interface BaseMapCodec<K,V>
    • decode

      public <T> DataResult<Pair<Map<K,V>,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<K>
      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(Map<K,V> 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<K>
      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