Package com.petrolpark.core.codec
Record Class ContextualListCodec<CONTEXT,E>
java.lang.Object
java.lang.Record
com.petrolpark.core.codec.ContextualListCodec<CONTEXT,E>
- All Implemented Interfaces:
ContextualCodec<CONTEXT,,List<E>> ContextualDecoder<CONTEXT,,List<E>> ContextualEncoder<CONTEXT,List<E>>
public record ContextualListCodec<CONTEXT,E> (ContextualCodec<CONTEXT,E> elementCodec, int minSize, int maxSize)
extends Record
implements ContextualCodec<CONTEXT,List<E>>
Copy of
ListCodec that accepts a context object when encoding and decoding-
Constructor Summary
ConstructorsConstructorDescriptionContextualListCodec(ContextualCodec<CONTEXT, E> elementCodec, int minSize, int maxSize) Creates an instance of aContextualListCodecrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theelementCodecrecord component.<T> com.mojang.serialization.DataResult<T> final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intmaxSize()Returns the value of themaxSizerecord component.intminSize()Returns the value of theminSizerecord component.toString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.petrolpark.core.codec.ContextualCodec
fieldOf, flatContextualXmap, optionalFieldOf, withContext, xmapMethods inherited from interface com.petrolpark.core.codec.ContextualDecoder
decode, flatContextualMap, map, parse, parseMethods inherited from interface com.petrolpark.core.codec.ContextualEncoder
comap, encodeStart, flatContextualComap
-
Constructor Details
-
ContextualListCodec
Creates an instance of aContextualListCodecrecord class.- Parameters:
elementCodec- the value for theelementCodecrecord componentminSize- the value for theminSizerecord componentmaxSize- the value for themaxSizerecord component
-
-
Method Details
-
encode
public <T> com.mojang.serialization.DataResult<T> encode(List<E> input, CONTEXT context, com.mojang.serialization.DynamicOps<T> ops, T prefix) - Specified by:
encodein interfaceContextualEncoder<CONTEXT,E>
-
decode
public <T> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<List<E>,T>> decode(com.mojang.serialization.DynamicOps<T> ops, CONTEXT context, T input) - Specified by:
decodein interfaceContextualDecoder<CONTEXT,E>
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
elementCodec
Returns the value of theelementCodecrecord component.- Returns:
- the value of the
elementCodecrecord component
-
minSize
public int minSize()Returns the value of theminSizerecord component.- Returns:
- the value of the
minSizerecord component
-
maxSize
public int maxSize()Returns the value of themaxSizerecord component.- Returns:
- the value of the
maxSizerecord component
-