Package org.moddingx.libx.config.mapper
Interface GenericValueMapper<T,E extends JsonElement,C>
- Type Parameters:
T
- The type that this mapper can serialise.E
- The JSON element type this mapper uses.C
- The element type. Should be a type variable in most cases.
public interface GenericValueMapper<T,E extends JsonElement,C>
A value mapper for a generic type. This will get the value mapper for the generic
that has been used to declare the config field. For example you could create a
value mapper for lists that would then get passed a value mapper for the elements
of the list so it can fully serialise it.
A limitation with these is that you can only have one generic parameter for
which you can get a value mapper. Only LibX builtin mappers can have multiple
of these.
When extending this, you should make the type argument
T
dependent on C
.
For example for lists, you should do
ListValueMapper<T> implements GenericValueMapper<List<T>, JsonArray, T>
.
Then you can register a ListValueMapper<?>
.-
Method Summary
Modifier and TypeMethodDescriptioncomment()
Returns a list of comment lines that will be added to the values specified in@Config
.correct
(JsonElement json, ValueMapper<C, JsonElement> mapper, ConfigCorrection<T> correction) createEditor
(ValueMapper<C, JsonElement> mapper, ValidatorInfo<?> validator) element()
Gets the class of the JSON element type this mapper uses.fromJson
(E json, ValueMapper<C, JsonElement> mapper) default T
fromNetwork
(net.minecraft.network.FriendlyByteBuf buffer, ValueMapper<C, JsonElement> mapper) int
The position which generic type argument should be used to retrieve a value mapper.toJson
(T value, ValueMapper<C, JsonElement> mapper) default void
toNetwork
(T value, net.minecraft.network.FriendlyByteBuf buffer, ValueMapper<C, JsonElement> mapper) type()
Gets the class of the type that this mapper can serialise.
-
Method Details
-
type
Gets the class of the type that this mapper can serialise. -
element
Gets the class of the JSON element type this mapper uses. -
getGenericElementPosition
int getGenericElementPosition()The position which generic type argument should be used to retrieve a value mapper. Indices start at 0. -
fromJson
- See Also:
-
toJson
- See Also:
-
fromNetwork
default T fromNetwork(net.minecraft.network.FriendlyByteBuf buffer, ValueMapper<C, JsonElement> mapper) - See Also:
-
toNetwork
default void toNetwork(T value, net.minecraft.network.FriendlyByteBuf buffer, ValueMapper<C, JsonElement> mapper) -
comment
Returns a list of comment lines that will be added to the values specified in@Config
. -
correct
default Optional<T> correct(JsonElement json, ValueMapper<C, JsonElement> mapper, ConfigCorrection<T> correction) -
createEditor
- See Also:
-