org.omnaest.utils.beans.autowired
Class ClassMapToAutowiredContainerAdapter<E>

java.lang.Object
  extended by org.omnaest.utils.beans.autowired.AutowiredContainerAbstract<E>
      extended by org.omnaest.utils.beans.autowired.ClassMapToAutowiredContainerAdapter<E>
All Implemented Interfaces:
Serializable, Iterable<E>, AutowiredContainer<E>

public class ClassMapToAutowiredContainerAdapter<E>
extends AutowiredContainerAbstract<E>

Adapter to allow Maps to be treated as AutowiredContainer. The key of the Map will be the Class of an element and the value will be the element itself.

Author:
Omnaest
See Also:
AutowiredContainer, Serialized Form

Constructor Summary
protected ClassMapToAutowiredContainerAdapter()
           
protected ClassMapToAutowiredContainerAdapter(Map<Class<? extends E>,E> classToObjectMap)
           
 
Method Summary
protected  Set<Class<? extends E>> determineAssignableTypeSet(Class<? extends E> type)
           
<O extends E>
Set<O>
getValueSet(Class<? extends O> type)
          Returns a Set for all values which can be assigned to the given Class.
 Iterator<E> iterator()
           
static
<E> AutowiredContainer<E>
newInstance(Map<Class<? extends E>,E> classToObjectMap)
          Creates a new instance of a AutowiredContainer for a given Map
static
<E> AutowiredContainer<E>
newInstanceUsingLinkedHashMap()
          Creates a new instance of a AutowiredContainer using a regular LinkedHashMap
 AutowiredContainer<E> put(E object)
          Adds an Object to the AutowiredContainer using its Object.getClass() as primary type.
<O extends E>
AutowiredContainer<E>
put(O object, Class<? extends O>... types)
          Adds an Object to the AutowiredContainer for one or more given Class types.
 AutowiredContainer<E> removeAllAssignableTo(Class<? extends E> type)
          Removes all elements within the AutowiredContainer which are Class.isAssignableFrom(Class) to the given type.
 AutowiredContainer<E> removeAllHavingExactTypeOf(Class<? extends E> type)
          Removes all elements within the AutowiredContainer which are put into the container with the given primary type.
 
Methods inherited from class org.omnaest.utils.beans.autowired.AutowiredContainerAbstract
containsAssignable, equals, getValue, hashCode, isEmpty, putAll, remove, size, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassMapToAutowiredContainerAdapter

protected ClassMapToAutowiredContainerAdapter(Map<Class<? extends E>,E> classToObjectMap)
Parameters:
classToObjectMap -

ClassMapToAutowiredContainerAdapter

protected ClassMapToAutowiredContainerAdapter()
See Also:
ClassMapToAutowiredContainerAdapter
Method Detail

newInstanceUsingLinkedHashMap

public static <E> AutowiredContainer<E> newInstanceUsingLinkedHashMap()
Creates a new instance of a AutowiredContainer using a regular LinkedHashMap

Returns:

newInstance

public static <E> AutowiredContainer<E> newInstance(Map<Class<? extends E>,E> classToObjectMap)
Creates a new instance of a AutowiredContainer for a given Map

Parameters:
classToObjectMap -
Returns:

getValueSet

public <O extends E> Set<O> getValueSet(Class<? extends O> type)
Description copied from interface: AutowiredContainer
Returns a Set for all values which can be assigned to the given Class.


determineAssignableTypeSet

protected Set<Class<? extends E>> determineAssignableTypeSet(Class<? extends E> type)
Parameters:
type -
Returns:

put

public AutowiredContainer<E> put(E object)
Description copied from interface: AutowiredContainer
Adds an Object to the AutowiredContainer using its Object.getClass() as primary type.

Returns:
this
See Also:
AutowiredContainer.put(Object, Class...), AutowiredContainer.putAll(Iterable)

iterator

public Iterator<E> iterator()

put

public <O extends E> AutowiredContainer<E> put(O object,
                                               Class<? extends O>... types)
Description copied from interface: AutowiredContainer
Adds an Object to the AutowiredContainer for one or more given Class types.

Returns:
this
See Also:
AutowiredContainer.put(Object)

removeAllHavingExactTypeOf

public AutowiredContainer<E> removeAllHavingExactTypeOf(Class<? extends E> type)
Description copied from interface: AutowiredContainer
Removes all elements within the AutowiredContainer which are put into the container with the given primary type.

Returns:
this
See Also:
AutowiredContainer.removeAllAssignableTo(Class)

removeAllAssignableTo

public AutowiredContainer<E> removeAllAssignableTo(Class<? extends E> type)
Description copied from interface: AutowiredContainer
Removes all elements within the AutowiredContainer which are Class.isAssignableFrom(Class) to the given type.

Returns:
this
See Also:
AutowiredContainer.removeAllHavingExactTypeOf(Class)


Copyright © 2013. All Rights Reserved.