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.

Serializers added to a builder will be prioritized based on registration order, so if multiple serializers could match a single type, the first-registered one will be used.

Since:
4.0.0
  • Method Details

    • register

      public <T> TypeSerializerCollection.Builder register(io.leangen.geantyref.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 accept
      serializer - 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 accept
      serializer - 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 against
      serializer - the serializer to serialize matching types with
      Returns:
      this builder
      Since:
      4.0.0
    • register

      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
    • registerAnnotated

      Register a type serializer matching against a given predicate, with type annotation information.
      Type Parameters:
      T - the type parameter
      Parameters:
      test - the predicate to match annotated types against
      serializer - the serializer to serialize matching types with
      Returns:
      this builder
      Since:
      4.2.0
      See Also:
    • registerExact

      public <T> TypeSerializerCollection.Builder registerExact(io.leangen.geantyref.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 when ArrayList<String> is queried.

      Type Parameters:
      T - the type to generify around
      Parameters:
      type - the type to accept
      serializer - 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 when ArrayList<String> is queried.

      Type Parameters:
      T - the type to generify around
      Parameters:
      type - the type to accept
      serializer - the serializer that will be serialized with
      Returns:
      this builder
      Since:
      4.0.0
    • registerExact

      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 when ArrayList<String> is queried.

      Type Parameters:
      T - value type
      Parameters:
      serializer - serializer to register
      Returns:
      this builder
      Since:
      4.0.0
    • registerAll

      Register all serializers from other 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

      Register a customized object mapper to handle ConfigSerializable-annotated objects.
      Parameters:
      factory - factory to retrieve object mappers from
      Returns:
      this builder
      Since:
      4.0.0
    • build

      Create a new type serializer collection.
      Returns:
      a newly created collection
      Since:
      4.0.0