Record Class ExtraCodecs.StrictUnboundedMapCodec<K,V>

java.lang.Object
java.lang.Record
net.minecraft.util.ExtraCodecs.StrictUnboundedMapCodec<K,V>
All Implemented Interfaces:
Codec<Map<K,V>>, BaseMapCodec<K,V>, Decoder<Map<K,V>>, Encoder<Map<K,V>>
Enclosing class:
ExtraCodecs

public static record ExtraCodecs.StrictUnboundedMapCodec<K,V>(Codec<K> keyCodec, Codec<V> elementCodec) extends Record implements BaseMapCodec<K,V>, Codec<Map<K,V>>
  • Field Details

    • keyCodec

      private final Codec<K> keyCodec
      The field for the keyCodec record component.
    • elementCodec

      private final Codec<V> elementCodec
      The field for the elementCodec record component.
  • Constructor Details

    • StrictUnboundedMapCodec

      public StrictUnboundedMapCodec(Codec<K> keyCodec, Codec<V> elementCodec)
      Creates an instance of a StrictUnboundedMapCodec record class.
      Parameters:
      keyCodec - the value for the keyCodec record component
      elementCodec - the value for the elementCodec record component
  • Method Details

    • decode

      public <T> DataResult<Map<K,V>> decode(DynamicOps<T> ops, MapLike<T> input)
      Specified by:
      decode in interface BaseMapCodec<K,V>
    • decode

      public <T> DataResult<Pair<Map<K,V>,T>> decode(DynamicOps<T> ops, T input)
      Specified by:
      decode in interface Decoder<K>
    • encode

      public <T> DataResult<T> encode(Map<K,V> input, DynamicOps<T> ops, T prefix)
      Specified by:
      encode in interface Encoder<K>
    • toString

      public 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.
    • keyCodec

      public Codec<K> keyCodec()
      Returns the value of the keyCodec record component.
      Specified by:
      keyCodec in interface BaseMapCodec<K,V>
      Returns:
      the value of the keyCodec record component
    • elementCodec

      public Codec<V> elementCodec()
      Returns the value of the elementCodec record component.
      Specified by:
      elementCodec in interface BaseMapCodec<K,V>
      Returns:
      the value of the elementCodec record component