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 Summary
Modifier and TypeMethodDescription@NotNull TypeSerializerRegistrycopy()Creates a copy of this registry.static @NotNull TypeSerializerRegistrycreate()Creates an empty registry.static @NotNull TypeSerializerRegistrydefaults()Creates a registry with default serializers for common types.<T> @Nullable TypeSerializer<T>Gets the serializer for an exact type match.<T> @Nullable TypeSerializer<T>getWithInheritance(@NotNull Class<T> type) Gets a serializer, checking superclasses and interfaces if no exact match exists.<T> voidregister(@NotNull Class<T> type, @NotNull TypeSerializer<T> serializer) Registers a serializer for a specific type.voidunregister(@NotNull Class<?> type) Unregisters the serializer for the given type, if present.
-
Method Details
-
register
Registers a serializer for a specific type.- Type Parameters:
T- the type parameter- Parameters:
type- the type to registerserializer- the serializer for that type
-
unregister
Unregisters the serializer for the given type, if present.- Parameters:
type- the type to unregister
-
get
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
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
Creates a copy of this registry.- Returns:
- a new registry with the same serializers
-
defaults
Creates a registry with default serializers for common types.- Returns:
- a new registry with defaults
-
create
Creates an empty registry.- Returns:
- a new empty registry
-