Package se.l4.commons.serialization
Interface SerializerCollection
- All Known Implementing Classes:
AbstractSerializerCollection,DefaultSerializerCollection,WrappedSerializerCollection
public interface SerializerCollection
Collection of
Serializers and resolvers.- Author:
- Andreas Holstenson
-
Method Summary
Modifier and Type Method Description SerializerCollectionbind(Class<?> type)Bind a certain type automatically discovering which serializer to use.<T> SerializerCollectionbind(Class<T> type, Serializer<T> serializer)Bind a given type to the specified serializer.<T> SerializerCollectionbind(Class<T> type, SerializerResolver<? extends T> resolver)Bind a given type to the specified resolver.<T> Serializer<T>find(Class<T> type)Find a serializer suitable for the specific type.<T> Serializer<T>find(Class<T> type, Annotation... hints)Find a serializer suitable for the specific type.Serializer<?>find(String name)Find a serializer based on its registered name.Serializer<?>find(String namespace, String name)Find a serializer based on its registered name.Serializer<?>find(Type type)Find a serializer suitable for the specified type.Serializer<?>find(Type type, Annotation... hints)Find a serializer suitable for the specified type.QualifiedNamefindName(Serializer<?> serializer)Find the name of the given serializer (if any).<T> Serializer<T>findVia(Class<? extends SerializerOrResolver<T>> resolver, Class<T> type, Annotation... hints)Find a serializer using a specificSerializerResolver.<T> Serializer<T>findVia(Class<? extends SerializerOrResolver<T>> resolver, Type type, Annotation... hints)Find a serializer using a specificSerializerResolver.InstanceFactorygetInstanceFactory()Get the current instance factory.SerializerResolver<?>getResolver(Class<?> type)Get the resolver this collection would use to resolve a serializer for the given type.booleanisSupported(Class<?> type)Get if the given type can be serialized.
-
Method Details
-
getInstanceFactory
Get the current instance factory.- Returns:
-
bind
Bind a certain type automatically discovering which serializer to use.- Parameters:
type-
-
bind
Bind a given type to the specified serializer.- Type Parameters:
T-- Parameters:
type-serializer-
-
bind
@NonNull <T> SerializerCollection bind(@NonNull Class<T> type, @NonNull SerializerResolver<? extends T> resolver)Bind a given type to the specified resolver. The resolver will be asked to resolve a more specific serializer based on type parameters.- Type Parameters:
T-- Parameters:
type-resolver-
-
find
Find a serializer suitable for the specific type.- Type Parameters:
T-- Parameters:
type-- Returns:
-
find
Find a serializer suitable for the specific type.- Type Parameters:
T-- Parameters:
type-- Returns:
-
find
Find a serializer suitable for the specified type.- Parameters:
type-- Returns:
-
find
Find a serializer suitable for the specified type.- Parameters:
type-- Returns:
-
find
Find a serializer based on its registered name.- Parameters:
name-- Returns:
-
find
Find a serializer based on its registered name.- Parameters:
namespace-name-- Returns:
-
findVia
@NonNull <T> Serializer<T> findVia(@NonNull Class<? extends SerializerOrResolver<T>> resolver, @NonNull Class<T> type, @NonNull Annotation... hints)Find a serializer using a specificSerializerResolver.- Parameters:
resolver-type-- Returns:
-
findVia
@NonNull <T> Serializer<T> findVia(@NonNull Class<? extends SerializerOrResolver<T>> resolver, @NonNull Type type, @NonNull Annotation... hints)Find a serializer using a specificSerializerResolver.- Parameters:
sOrR-type-- Returns:
-
getResolver
Get the resolver this collection would use to resolve a serializer for the given type.- Parameters:
type-- Returns:
-
isSupported
Get if the given type can be serialized.- Parameters:
type-- Returns:
-
findName
Find the name of the given serializer (if any).- Parameters:
serializer-- Returns:
-