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
Modifier and TypeFieldDescriptionprivate final com.mojang.serialization.Codec
<T> The field for thealternative
record component.private final com.mojang.serialization.Codec
<T> The field for thecodec
record 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
ModifierConstructorDescriptionprivate
AlternativeCodec
(com.mojang.serialization.Codec<T> codec, com.mojang.serialization.Codec<T> alternative) Creates an instance of aAlternativeCodec
record class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.Codec
<T> Returns the value of thealternative
record component.com.mojang.serialization.Codec
<T> codec()
Returns the value of thecodec
record 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 boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
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, 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
-
Field Details
-
codec
The field for thecodec
record component. -
alternative
The field for thealternative
record component.
-
-
Constructor Details
-
AlternativeCodec
private AlternativeCodec(com.mojang.serialization.Codec<T> codec, com.mojang.serialization.Codec<T> alternative) Creates an instance of aAlternativeCodec
record class.- Parameters:
codec
- the value for thecodec
record componentalternative
- the value for thealternative
record 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:
decode
in 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:
encode
in 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 thecodec
record component.- Returns:
- the value of the
codec
record component
-
alternative
Returns the value of thealternative
record component.- Returns:
- the value of the
alternative
record component
-