Package org.springframework.data.util
Interface CustomCollectionRegistrar
public interface CustomCollectionRegistrar
An SPI to register custom collection types. Implementations need to be registered via
META-INF/spring.factories
.- Since:
- 2.7
- Author:
- Oliver Drotbohm
-
Method Summary
Modifier and TypeMethodDescriptiondefault Collection<Class<?>>
Return all types that are considered valid return types for methods using pagination.Collection<Class<?>>
Returns all types that are supposed to be considered collections.Collection<Class<?>>
Returns all types that are supposed to be considered maps.default boolean
Returns whether the registrar is available, meaning whether it can be used at runtime.void
registerConvertersIn
(ConverterRegistry registry) Register all converters to convert instances of the types returned bygetCollectionTypes()
andgetMapTypes()
from an to their Java-native counterparts.Returns aFunction
to convert instances of their Java-native counterpart.
-
Method Details
-
isAvailable
default boolean isAvailable()Returns whether the registrar is available, meaning whether it can be used at runtime. Primary use is for implementations that need to perform a classpath check to prevent the actual methods loading classes that might not be available.- Returns:
- whether the registrar is available
-
getMapTypes
Collection<Class<?>> getMapTypes()Returns all types that are supposed to be considered maps. Primary requirement is key and value generics expressed in the first and second generics parameter of the type. Also, the types should be transformable into their Java-native equivalent usingtoJavaNativeCollection()
.- Returns:
- will never be null.
- See Also:
-
getCollectionTypes
Collection<Class<?>> getCollectionTypes()Returns all types that are supposed to be considered collections. Primary requirement is that their component types are expressed as first generics parameter. Also, the types should be transformable into their Java-native equivalent usingtoJavaNativeCollection()
.- Returns:
- will never be null.
- See Also:
-
getAllowedPaginationReturnTypes
Return all types that are considered valid return types for methods using pagination. These are usually collections with a stable order, likeList
but noSet
s, as pagination usually involves sorting.- Returns:
- will never be null.
-
registerConvertersIn
Register all converters to convert instances of the types returned bygetCollectionTypes()
andgetMapTypes()
from an to their Java-native counterparts.- Parameters:
registry
- will never be null.
-
toJavaNativeCollection
Returns aFunction
to convert instances of their Java-native counterpart.- Returns:
- must not be null.
-