Interface TypeLookupFactory

  • All Known Subinterfaces:
    BeanFactory<ID>
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.


    @FunctionalInterface
    public interface TypeLookupFactory
    The TypeLookupFactory defines the functionality which must be provided in order to represent a factory for object creation of *ALL* objects being of a requested type (in contrast to the TypeFactory and the LookupFactory which create instances of a predefined type specified with a generic argument). Many alternative implementations of a TypeLookupFactory may may exist which construct the instances their way.

    Having factories that generic as we define it here, we are able to decouple our business logic from any specific framework: Your business logic must not know anything about how the instances are generated. It mainly just needs to know how to use the TypeLookupFactory. It is up to the application "end point", i.e. a command line tool with a main-method or a web-application to finally decide which factory to use.

    Depending on the implementation used or configuration provided, the TypeLookupFactory may return singletons or dedicated separate instances when queried for instances.

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      <T> java.util.Set<T> createInstances​(java.lang.Class<?> aType)
      This method creates / retrieves an all instances of the given type.
      default <T> java.util.Set<T> toInstances​(java.lang.Class<?> aType, java.util.Map<java.lang.String,java.lang.String> aProperties)
      This method creates / retrieves all instances of the given type.
    • Method Detail

      • createInstances

        <T> java.util.Set<T> createInstances​(java.lang.Class<?> aType)
        This method creates / retrieves an all instances of the given type.
        Type Parameters:
        T - The type which is to be fabricated by the factory method.
        Parameters:
        aType - The type identifying the instances to be created / retrieved.
        Returns:
        A set with all instance of the required type for the given type.
        Throws:
        java.lang.ClassCastException - in case the fabricated type is not type compatible with the required type T.
      • toInstances

        default <T> java.util.Set<T> toInstances​(java.lang.Class<?> aType,
                                                 java.util.Map<java.lang.String,java.lang.String> aProperties)
        This method creates / retrieves all instances of the given type.
        Type Parameters:
        T - The type which is to be fabricated by the factory method.
        Parameters:
        aType - The type identifying the instances to be created / retrieved.
        aProperties - The dynamic properties which are used to configure the desired bean.
        Returns:
        A set with all instance of the required type for the given type.
        Throws:
        java.lang.ClassCastException - in case the fabricated type is not type compatible with the required type T.