Class RecordSerializer<R extends Record>
java.lang.Object
dev.siroshun.configapi.core.serialization.record.RecordSerializer<R>
- Type Parameters:
R- the type of theRecord
- All Implemented Interfaces:
Serializer<R,,MapNode> Function<R,MapNode>
@Experimental
public final class RecordSerializer<R extends Record>
extends Object
implements Serializer<R,MapNode>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRecordSerializer.Builder<R extends Record>ARecordSerializer.Builderclass forRecordSerializer. -
Method Summary
Modifier and TypeMethodDescriptionstatic <R extends Record>
@NotNull RecordSerializer.Builder<R>builder()Creates a newRecordSerializer.BuilderofRecordSerializer.static <R extends Record>
@NotNull RecordSerializer<R>create(@NotNull KeyGenerator keyGenerator) Creates aRecordSerializerwith theKeyGenerator.@NotNull MapNodeSerializes the object.@NotNull MapNodeserializeDefault(@NotNull Class<? extends R> clazz) Creates a defaultMapNodefrom the given record class.static <R extends Record>
@NotNull RecordSerializer<R>Gets the defaultRecordSerializer.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.Serializer
andThen, apply, compose
-
Method Details
-
serializer
Gets the defaultRecordSerializer.This serializer uses
KeyGenerator.AS_IS.- Type Parameters:
R- the type of theRecord- Returns:
- the default
RecordSerializer
-
create
@NotNull public static <R extends Record> @NotNull RecordSerializer<R> create(@NotNull @NotNull KeyGenerator keyGenerator) Creates aRecordSerializerwith theKeyGenerator.If specifying
KeyGenerator.AS_IS, this method returnsserializer().- Type Parameters:
R- the type of theRecord- Parameters:
keyGenerator- theKeyGeneratorto generate key name- Returns:
- the
RecordSerializer
-
builder
Creates a newRecordSerializer.BuilderofRecordSerializer.- Type Parameters:
R- the type of theRecord- Returns:
- a new
RecordSerializer.BuilderofRecordSerializer
-
serialize
Serializes the object.- Specified by:
serializein interfaceSerializer<R extends Record,MapNode> - Parameters:
input- the object to serialize- Returns:
- the serialized result
- Throws:
SerializationException- ifSerializerfor the custom objects is not found, etc
-
serializeDefault
@NotNull public @NotNull MapNode serializeDefault(@NotNull @NotNull Class<? extends R> clazz) throws SerializationException Creates a defaultMapNodefrom the given record class.- Parameters:
clazz- theRecordto createMapNode- Returns:
- a default
MapNodeof the given record class - Throws:
SerializationException- ifSerializerfor the custom objects is not found, etc
-