Class TypeSerializerCollection

java.lang.Object
ninja.leaping.configurate.objectmapping.serialize.TypeSerializerCollection

public class TypeSerializerCollection
extends Object
A calculated collection of TypeSerializers
  • Method Details

    • defaults

      Gets the default TypeSerializers. While this collection is mutable, starting with Configurate 4.0 type serializer collections will be immutable, so mutability should not be relied on. Instead, a new child of this collection should be used to register any custom serializers.
      Returns:
      The default serializers
    • create

    • get

      public <T> TypeSerializer<T> get​(TypeToken<T> type)
    • registerType

      @Deprecated public <T> TypeSerializerCollection registerType​(TypeToken<T> type, TypeSerializer<? super T> serializer)
      Deprecated.
      Use #register(TypeToken, TypeSerializer) instead
      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
    • register

      public <T> TypeSerializerCollection 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 accept
      serializer - The serializer that will be serialized with
      Returns:
      this
    • registerPredicate

      @Deprecated public <T> TypeSerializerCollection registerPredicate​(Predicate<TypeToken<T>> test, TypeSerializer<? super T> serializer)
      Deprecated.
      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
    • register

      public <T> TypeSerializerCollection register​(Predicate<TypeToken<T>> 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
    • register

      public <T> TypeSerializerCollection register​(ScalarSerializer<T> serializer)
      Register a scalar serializer under its appropriate type. Serializers registered will match all subclasses
      Type Parameters:
      T - The type to generify around
      Parameters:
      serializer - The serializer that will be serialized with
      Returns:
      this
    • newChild