Class RecordDeserializer<R extends Record>
java.lang.Object
dev.siroshun.configapi.core.serialization.record.RecordDeserializer<R>
- Type Parameters:
R- the type of theRecord
- All Implemented Interfaces:
Deserializer<MapNode,,R> Function<MapNode,R>
@Experimental
public final class RecordDeserializer<R extends Record>
extends Object
implements Deserializer<MapNode,R>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRecordDeserializer.Builder<R extends Record>ARecordDeserializer.Builderclass forRecordDeserializer. -
Method Summary
Modifier and TypeMethodDescriptionstatic <R extends Record>
@NotNull RecordDeserializer.Builder<R>Creates a newRecordDeserializer.Builderof the specifiedRecordclass.static <R extends Record>
@NotNull RecordDeserializer.Builder<R>builder(R defaultRecord) Creates a newRecordDeserializer.Builderwith the default record.static <R extends Record>
@NotNull RecordDeserializer<R>CreatesRecordDeserializerof the specifiedRecordclass.static <R extends Record>
@NotNull RecordDeserializer<R>create(@NotNull Class<? extends R> recordClass, @NotNull KeyGenerator keyGenerator) CreatesRecordDeserializerof the specifiedRecordclass.static <R extends Record>
@NotNull RecordDeserializer<R>create(R defaultRecord) CreatesRecordDeserializerwith the default record.static <R extends Record>
@NotNull RecordDeserializer<R>create(R defaultRecord, @NotNull KeyGenerator keyGenerator) CreatesRecordDeserializerwith the default record.deserialize(@NotNull MapNode input) Deserializes the object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.siroshun.configapi.core.serialization.Deserializer
andThen, apply, compose
-
Method Details
-
create
@Contract("_ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer<R> create(@NotNull @NotNull Class<? extends R> recordClass) CreatesRecordDeserializerof the specifiedRecordclass.- Type Parameters:
R- the type of theRecord- Parameters:
recordClass- the class of theRecord- Returns:
RecordDeserializerof the specifiedRecordclass
-
create
@Contract("_, _ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer<R> create(@NotNull @NotNull Class<? extends R> recordClass, @NotNull @NotNull KeyGenerator keyGenerator) CreatesRecordDeserializerof the specifiedRecordclass.- Type Parameters:
R- the type of theRecord- Parameters:
recordClass- the class of theRecordkeyGenerator- theKeyGeneratorto generate keys from field names- Returns:
RecordDeserializerof the specifiedRecordclass
-
create
@Contract("_ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer<R> create(@NotNull R defaultRecord) CreatesRecordDeserializerwith the default record.- Type Parameters:
R- the type of theRecord- Parameters:
defaultRecord- the defaultRecordto get the default value if the value is not found in theMapNode- Returns:
RecordDeserializerof the specifiedRecordclass
-
create
@Contract("_, _ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer<R> create(@NotNull R defaultRecord, @NotNull @NotNull KeyGenerator keyGenerator) CreatesRecordDeserializerwith the default record.- Type Parameters:
R- the type of theRecord- Parameters:
defaultRecord- the defaultRecordto get the default value if the value is not found in theMapNodekeyGenerator- theKeyGeneratorto generate keys from field names- Returns:
RecordDeserializerof the specifiedRecordclass
-
builder
@Contract("_ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer.Builder<R> builder(@NotNull @NotNull Class<? extends R> recordClass) Creates a newRecordDeserializer.Builderof the specifiedRecordclass.- Type Parameters:
R- the type of theRecord- Parameters:
recordClass- the class of theRecord- Returns:
RecordDeserializer.Builderof the specifiedRecordclass
-
builder
@Contract("_ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer.Builder<R> builder(@NotNull R defaultRecord) Creates a newRecordDeserializer.Builderwith the default record.- Type Parameters:
R- the type of theRecord- Parameters:
defaultRecord- the defaultRecordto get the default value if the value is not found in theMapNode- Returns:
RecordDeserializer.Builderof the specifiedRecordclass
-
deserialize
Deserializes the object.- Specified by:
deserializein interfaceDeserializer<MapNode,R extends Record> - Parameters:
input- the object to deserialize- Returns:
- the deserialized result
- Throws:
SerializationException- ifDeserializerfor the custom objects is not found, etc
-