Record Class NeoForgeExtraCodecs.AlternativeCodec<T>
java.lang.Object
java.lang.Record
net.neoforged.neoforge.common.util.NeoForgeExtraCodecs.AlternativeCodec<T>
- All Implemented Interfaces:
com.mojang.serialization.Codec<T>,com.mojang.serialization.Decoder<T>,com.mojang.serialization.Encoder<T>
- Enclosing class:
NeoForgeExtraCodecs
-
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
FieldsModifier and TypeFieldDescriptionprivate final com.mojang.serialization.Codec<T> The field for thealternativerecord component.private final com.mojang.serialization.Codec<T> The field for thecodecrecord component.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
ConstructorsModifierConstructorDescriptionprivateAlternativeCodec(com.mojang.serialization.Codec<T> codec, com.mojang.serialization.Codec<T> alternative) Creates an instance of aAlternativeCodecrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.Codec<T> Returns the value of thealternativerecord component.com.mojang.serialization.Codec<T> codec()Returns the value of thecodecrecord component.<T1> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<T, T1>> decode(com.mojang.serialization.DynamicOps<T1> ops, T1 input) <T1> com.mojang.serialization.DataResult<T1> final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.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.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, xmapMethods inherited from interface com.mojang.serialization.Decoder
boxed, decode, flatMap, map, parse, parse, simple, terminalMethods inherited from interface com.mojang.serialization.Encoder
comap, encodeStart, flatComap
-
Field Details
-
codec
The field for thecodecrecord component. -
alternative
The field for thealternativerecord component.
-
-
Constructor Details
-
AlternativeCodec
private AlternativeCodec(com.mojang.serialization.Codec<T> codec, com.mojang.serialization.Codec<T> alternative) Creates an instance of aAlternativeCodecrecord class.- Parameters:
codec- the value for thecodecrecord componentalternative- the value for thealternativerecord component
-
-
Method Details
-
decode
public <T1> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<T,T1>> decode(com.mojang.serialization.DynamicOps<T1> ops, T1 input) - Specified by:
decodein interfacecom.mojang.serialization.Decoder<T>
-
encode
public <T1> com.mojang.serialization.DataResult<T1> encode(T input, com.mojang.serialization.DynamicOps<T1> ops, T1 prefix) - Specified by:
encodein interfacecom.mojang.serialization.Encoder<T>
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
codec
Returns the value of thecodecrecord component.- Returns:
- the value of the
codecrecord component
-
alternative
Returns the value of thealternativerecord component.- Returns:
- the value of the
alternativerecord component
-