org.omnaest.utils.beans.autowired
Class TypeToAutowiredPropertyContainerAdapter<B>

java.lang.Object
  extended by org.omnaest.utils.beans.autowired.AutowiredContainerAbstract<Object>
      extended by org.omnaest.utils.beans.autowired.TypeToAutowiredPropertyContainerAdapter<B>
Type Parameters:
B -
All Implemented Interfaces:
Serializable, Iterable<Object>, AutowiredContainer<Object>, AutowiredPropertyContainer

public class TypeToAutowiredPropertyContainerAdapter<B>
extends AutowiredContainerAbstract<Object>
implements AutowiredPropertyContainer

Adapter to create a Map view on an underlying Java Bean object. Modifications to the bean or the map will be reflected to each other.

Author:
Omnaest
See Also:
PropertynameMapToTypeAdapter, Serialized Form

Field Summary
protected  B bean
           
protected  Map<String,BeanPropertyAccessor<B>> propertynameToBeanPropertyAccessorMap
           
protected  Map<Class<?>,Set<BeanPropertyAccessor<B>>> propertyTypeToBeanPropertyAccessorSetMap
           
 
Constructor Summary
protected TypeToAutowiredPropertyContainerAdapter(B bean)
           
 
Method Summary
<O> Map<String,O>
getPropertynameToValueMap(Class<O> type)
          Returns a Map for all properties which can be assigned to the given Class.
protected
<O> Map<String,O>
getPropertynameToValueMapForArbitraryType(Class<?> type)
           
<O> Set<O>
getValueSet(Class<? extends O> type)
          Returns a Set for all values which can be assigned to the given Class.
 Iterator<Object> iterator()
           
static
<B> AutowiredPropertyContainer
newInstance(B bean)
          Factory method to create a Map view on a given Java Bean object.
 AutowiredContainer<Object> put(Object object)
          Adds an Object to the AutowiredContainer using its Object.getClass() as primary type.
<O> AutowiredContainer<Object>
put(O object, Class<? extends O>... types)
          Adds an Object to the AutowiredContainer for one or more given Class types.
 AutowiredPropertyContainer put(String propertyname, Object value)
          Adds an Object to the AutowiredPropertyContainer.
 AutowiredContainer<Object> removeAllAssignableTo(Class<? extends Object> type)
          Removes all elements within the AutowiredContainer which are Class.isAssignableFrom(Class) to the given type.
 AutowiredContainer<Object> removeAllHavingExactTypeOf(Class<? extends Object> 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
 
Methods inherited from interface org.omnaest.utils.beans.autowired.AutowiredContainer
containsAssignable, getValue, isEmpty, putAll, remove, size
 

Field Detail

bean

protected B bean

propertynameToBeanPropertyAccessorMap

protected Map<String,BeanPropertyAccessor<B>> propertynameToBeanPropertyAccessorMap

propertyTypeToBeanPropertyAccessorSetMap

protected Map<Class<?>,Set<BeanPropertyAccessor<B>>> propertyTypeToBeanPropertyAccessorSetMap
Constructor Detail

TypeToAutowiredPropertyContainerAdapter

protected TypeToAutowiredPropertyContainerAdapter(B bean)
Parameters:
bean -
See Also:
newInstance(Object)
Method Detail

newInstance

public static <B> AutowiredPropertyContainer newInstance(B bean)
Factory method to create a Map view on a given Java Bean object. Changes to this map will be translated to the Java Bean object and vice versa.

Type Parameters:
B -
Parameters:
bean -
Returns:

put

public <O> AutowiredContainer<Object> 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.

Specified by:
put in interface AutowiredContainer<Object>
Returns:
this
See Also:
AutowiredContainer.put(Object)

put

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

Specified by:
put in interface AutowiredContainer<Object>
Returns:
this
See Also:
AutowiredContainer.put(Object, Class...), AutowiredContainer.putAll(Iterable)

put

public AutowiredPropertyContainer put(String propertyname,
                                      Object value)
Description copied from interface: AutowiredPropertyContainer
Adds an Object to the AutowiredPropertyContainer. This will update all properties of the underlying Java Bean object which can be assigned by the given Object.

Specified by:
put in interface AutowiredPropertyContainer
Returns:
this

getPropertynameToValueMap

public <O> Map<String,O> getPropertynameToValueMap(Class<O> type)
Description copied from interface: AutowiredPropertyContainer
Returns a Map for all properties which can be assigned to the given Class. The Map has the property names as key and the values of the properties as values.

Specified by:
getPropertynameToValueMap in interface AutowiredPropertyContainer

getPropertynameToValueMapForArbitraryType

protected <O> Map<String,O> getPropertynameToValueMapForArbitraryType(Class<?> type)

getValueSet

public <O> 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.

Specified by:
getValueSet in interface AutowiredContainer<Object>

iterator

public Iterator<Object> iterator()
Specified by:
iterator in interface Iterable<Object>

removeAllHavingExactTypeOf

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

Specified by:
removeAllHavingExactTypeOf in interface AutowiredContainer<Object>
Returns:
this
See Also:
AutowiredContainer.removeAllAssignableTo(Class)

removeAllAssignableTo

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

Specified by:
removeAllAssignableTo in interface AutowiredContainer<Object>
Returns:
this
See Also:
AutowiredContainer.removeAllHavingExactTypeOf(Class)


Copyright © 2013. All Rights Reserved.