Interface TypeSerializerRegistry

All Known Implementing Classes:
DefaultTypeSerializerRegistry

public interface TypeSerializerRegistry
Registry for type serializers with inheritance support.

Provides methods to register and retrieve serializers for specific types, with fallback to superclass/interface serializers when exact matches aren't found.

  • Method Details

    • register

      <T> void register(@NotNull @NotNull Class<T> type, @NotNull @NotNull TypeSerializer<T> serializer)
      Registers a serializer for a specific type.
      Type Parameters:
      T - the type parameter
      Parameters:
      type - the type to register
      serializer - the serializer for that type
    • unregister

      void unregister(@NotNull @NotNull Class<?> type)
      Unregisters the serializer for the given type, if present.
      Parameters:
      type - the type to unregister
    • get

      @Nullable <T> @Nullable TypeSerializer<T> get(@NotNull @NotNull Class<T> type)
      Gets the serializer for an exact type match.
      Type Parameters:
      T - the type parameter
      Parameters:
      type - the type to look up
      Returns:
      the serializer, or null if not found
    • getWithInheritance

      @Nullable <T> @Nullable TypeSerializer<T> getWithInheritance(@NotNull @NotNull Class<T> type)
      Gets a serializer, checking superclasses and interfaces if no exact match exists.
      Type Parameters:
      T - the type parameter
      Parameters:
      type - the type to look up
      Returns:
      the serializer, or null if not found
    • copy

      @NotNull @NotNull TypeSerializerRegistry copy()
      Creates a copy of this registry.
      Returns:
      a new registry with the same serializers
    • defaults

      @NotNull static @NotNull TypeSerializerRegistry defaults()
      Creates a registry with default serializers for common types.
      Returns:
      a new registry with defaults
    • create

      @NotNull static @NotNull TypeSerializerRegistry create()
      Creates an empty registry.
      Returns:
      a new empty registry