Record Class SetCodec<E>

java.lang.Object
java.lang.Record
com.portingdeadmods.portingdeadlibs.utils.codec.SetCodec<E>
All Implemented Interfaces:
com.mojang.serialization.Codec<Set<E>>, com.mojang.serialization.Decoder<Set<E>>, com.mojang.serialization.Encoder<Set<E>>

public record SetCodec<E>(com.mojang.serialization.Codec<E> elementCodec, int minSize, int maxSize, Supplier<? extends Set<E>> setSupplier) extends Record implements com.mojang.serialization.Codec<Set<E>>
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.mojang.serialization.Codec

    com.mojang.serialization.Codec.RecursiveCodec<T>, com.mojang.serialization.Codec.ResultFunction<A>

    Nested classes/interfaces inherited from interface com.mojang.serialization.Decoder

    com.mojang.serialization.Decoder.Boxed<A>, com.mojang.serialization.Decoder.Simple<A>, com.mojang.serialization.Decoder.Terminal<A>
  • Field Summary

    Fields inherited from interface com.mojang.serialization.Codec

    BOOL, BYTE, BYTE_BUFFER, DOUBLE, EMPTY, FLOAT, INT, INT_STREAM, LONG, LONG_STREAM, PASSTHROUGH, SHORT, STRING
  • Constructor Summary

    Constructors
    Constructor
    Description
    SetCodec(com.mojang.serialization.Codec<E> elementCodec, int minSize, int maxSize, Supplier<? extends Set<E>> setSupplier)
    Creates an instance of a SetCodec record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<Set<E>,T>>
    decode(com.mojang.serialization.DynamicOps<T> ops, T input)
     
    com.mojang.serialization.Codec<E>
    Returns the value of the elementCodec record component.
    <T> com.mojang.serialization.DataResult<T>
    encode(Set<E> input, com.mojang.serialization.DynamicOps<T> ops, T prefix)
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the maxSize record component.
    int
    Returns the value of the minSize record component.
    Supplier<? extends Set<E>>
    Returns the value of the setSupplier record component.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.mojang.serialization.Codec

    comapFlatMap, deprecated, dispatch, dispatch, dispatchMap, dispatchMap, dispatchStable, fieldOf, flatComapMap, flatXmap, lenientOptionalFieldOf, lenientOptionalFieldOf, lenientOptionalFieldOf, lenientOptionalFieldOf, listOf, listOf, mapResult, optionalFieldOf, optionalFieldOf, optionalFieldOf, optionalFieldOf, orElse, orElse, orElse, orElseGet, orElseGet, orElseGet, partialDispatch, promotePartial, sizeLimitedListOf, stable, validate, withLifecycle, xmap

    Methods inherited from interface com.mojang.serialization.Decoder

    boxed, decode, flatMap, map, parse, parse, simple, terminal

    Methods inherited from interface com.mojang.serialization.Encoder

    comap, encodeStart, flatComap
  • Constructor Details

    • SetCodec

      public SetCodec(com.mojang.serialization.Codec<E> elementCodec, int minSize, int maxSize, Supplier<? extends Set<E>> setSupplier)
      Creates an instance of a SetCodec record class.
      Parameters:
      elementCodec - the value for the elementCodec record component
      minSize - the value for the minSize record component
      maxSize - the value for the maxSize record component
      setSupplier - the value for the setSupplier record component
  • Method Details

    • encode

      public <T> com.mojang.serialization.DataResult<T> encode(Set<E> input, com.mojang.serialization.DynamicOps<T> ops, T prefix)
      Specified by:
      encode in interface com.mojang.serialization.Encoder<E>
    • decode

      public <T> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<Set<E>,T>> decode(com.mojang.serialization.DynamicOps<T> ops, T input)
      Specified by:
      decode in interface com.mojang.serialization.Decoder<E>
    • 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. 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.
    • elementCodec

      public com.mojang.serialization.Codec<E> elementCodec()
      Returns the value of the elementCodec record component.
      Returns:
      the value of the elementCodec record component
    • minSize

      public int minSize()
      Returns the value of the minSize record component.
      Returns:
      the value of the minSize record component
    • maxSize

      public int maxSize()
      Returns the value of the maxSize record component.
      Returns:
      the value of the maxSize record component
    • setSupplier

      public Supplier<? extends Set<E>> setSupplier()
      Returns the value of the setSupplier record component.
      Returns:
      the value of the setSupplier record component