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 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 using toJavaNativeCollection().
      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 using toJavaNativeCollection().
      Returns:
      will never be null.
      See Also:
    • getAllowedPaginationReturnTypes

      default Collection<Class<?>> getAllowedPaginationReturnTypes()
      Return all types that are considered valid return types for methods using pagination. These are usually collections with a stable order, like List but no Sets, as pagination usually involves sorting.
      Returns:
      will never be null.
    • registerConvertersIn

      void registerConvertersIn(org.springframework.core.convert.converter.ConverterRegistry registry)
      Register all converters to convert instances of the types returned by getCollectionTypes() and getMapTypes() from an to their Java-native counterparts.
      Parameters:
      registry - will never be null.
    • toJavaNativeCollection

      Function<Object,Object> toJavaNativeCollection()
      Returns a Function to convert instances of their Java-native counterpart.
      Returns:
      must not be null.