Class TypeSerializerCollection.Builder
- java.lang.Object
-
- org.spongepowered.configurate.serialize.TypeSerializerCollection.Builder
-
- Enclosing class:
- TypeSerializerCollection
public static class TypeSerializerCollection.Builder extends Object
A builder to construct new serializer collections.- Since:
- 4.0.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TypeSerializerCollection
build()
Create a new type serializer collection.<T> TypeSerializerCollection.Builder
register(TypeToken<T> type, TypeSerializer<? super T> serializer)
Register a type serializer for a given type.<T> TypeSerializerCollection.Builder
register(Class<T> type, TypeSerializer<? super T> serializer)
Register a type serializer for a given type.<T> TypeSerializerCollection.Builder
register(Predicate<Type> test, TypeSerializer<? super T> serializer)
Register a type serializer matching against a given predicate.<T> TypeSerializerCollection.Builder
register(ScalarSerializer<T> serializer)
Register a scalar serializer with its own attached type token.TypeSerializerCollection.Builder
registerAll(TypeSerializerCollection other)
Register all serializers fromother
into this collection.TypeSerializerCollection.Builder
registerAnnotatedObjects(ObjectMapper.Factory factory)
Register a customized object mapper to handleConfigSerializable
-annotated objects.<T> TypeSerializerCollection.Builder
registerExact(TypeToken<T> type, TypeSerializer<? super T> serializer)
Register an exact type serializer for a given type.<T> TypeSerializerCollection.Builder
registerExact(Class<T> type, TypeSerializer<? super T> serializer)
Register an exact type serializer for a given type.<T> TypeSerializerCollection.Builder
registerExact(ScalarSerializer<T> serializer)
Register a scalar serializer with its own attached type token.
-
-
-
Method Detail
-
register
public <T> TypeSerializerCollection.Builder register(TypeToken<T> type, TypeSerializer<? super T> serializer)
Register a type serializer for a given type.Serializers registered will match all subclasses of the provided type, as well as unwrapped primitive equivalents of the type.
- Type Parameters:
T
- the type to generify around- Parameters:
type
- the type to acceptserializer
- the serializer that will be serialized with- Returns:
- this builder
- Since:
- 4.0.0
-
register
public <T> TypeSerializerCollection.Builder register(Class<T> type, TypeSerializer<? super T> serializer)
Register a type serializer for a given type.Serializers registered will match all subclasses of the provided type, as well as unboxed primitive equivalents of the type.
- Type Parameters:
T
- the type to generify around- Parameters:
type
- the type to acceptserializer
- the serializer that will be serialized with- Returns:
- this builder
- Since:
- 4.0.0
-
register
public <T> TypeSerializerCollection.Builder register(Predicate<Type> test, TypeSerializer<? super T> serializer)
Register a type serializer matching against a given predicate.- Type Parameters:
T
- the type parameter- Parameters:
test
- the predicate to match types againstserializer
- the serializer to serialize matching types with- Returns:
- this builder
- Since:
- 4.0.0
-
register
public <T> TypeSerializerCollection.Builder register(ScalarSerializer<T> serializer)
Register a scalar serializer with its own attached type token.Serializers registered will match all subclasses of the provided type, as well as unboxed primitive equivalents of the type.
- Type Parameters:
T
- value type- Parameters:
serializer
- serializer to register- Returns:
- this builder
- Since:
- 4.0.0
-
registerExact
public <T> TypeSerializerCollection.Builder registerExact(TypeToken<T> type, TypeSerializer<? super T> serializer)
Register an exact type serializer for a given type.Serializers will only match exact object types. For example, a serializer registered for
List<String>
would not match whenArrayList<String>
is queried.- Type Parameters:
T
- the type to generify around- Parameters:
type
- the type to acceptserializer
- the serializer that will be serialized with- Returns:
- this builder
- Since:
- 4.0.0
-
registerExact
public <T> TypeSerializerCollection.Builder registerExact(Class<T> type, TypeSerializer<? super T> serializer)
Register an exact type serializer for a given type.Serializers will only match exact object types. For example, a serializer registered for
List<String>
would not match whenArrayList<String>
is queried.- Type Parameters:
T
- the type to generify around- Parameters:
type
- the type to acceptserializer
- the serializer that will be serialized with- Returns:
- this builder
- Since:
- 4.0.0
-
registerExact
public <T> TypeSerializerCollection.Builder registerExact(ScalarSerializer<T> serializer)
Register a scalar serializer with its own attached type token.Serializers will only match exact object types. For example, a serializer registered for
List<String>
would not match whenArrayList<String>
is queried.- Type Parameters:
T
- value type- Parameters:
serializer
- serializer to register- Returns:
- this builder
- Since:
- 4.0.0
-
registerAll
public TypeSerializerCollection.Builder registerAll(TypeSerializerCollection other)
Register all serializers fromother
into this collection.Creating a child collection should be preferred, but when merging multiple sets of serializers together, directly adding other collections may be the best choice.
- Parameters:
other
- source collection- Returns:
- this builder
- Since:
- 4.0.0
-
registerAnnotatedObjects
public TypeSerializerCollection.Builder registerAnnotatedObjects(ObjectMapper.Factory factory)
Register a customized object mapper to handleConfigSerializable
-annotated objects.- Parameters:
factory
- factory to retrieve object mappers from- Returns:
- this builder
- Since:
- 4.0.0
-
build
public TypeSerializerCollection build()
Create a new type serializer collection.- Returns:
- a newly created collection
- Since:
- 4.0.0
-
-