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

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

public class TypeToAutowiredPropertyContainerAdapter<B>
extends 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:
MapToTypeAdapter

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> clazz)
          Returns a Map for all properties which can be assigned to the given Class.
<O> O
getValue(Class<O> clazz)
          Returns the value of the property which can be assigned as value to the given Class type.
<O> Set<O>
getValueSet(Class<O> clazz)
          Returns a Set for all properties 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.
 int put(Object value)
          Adds an Object to the AutowiredPropertyContainer.
 boolean put(String propertyname, Object value)
          Adds an Object to the AutowiredPropertyContainer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 int put(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:
the number of assigned properties

put

public boolean 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:
true : assign was successful

getPropertynameToValueMap

public <O> Map<String,O> getPropertynameToValueMap(Class<O> clazz)
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

getValueSet

public <O> Set<O> getValueSet(Class<O> clazz)
Description copied from interface: AutowiredPropertyContainer
Returns a Set for all properties which can be assigned to the given Class.

Specified by:
getValueSet in interface AutowiredPropertyContainer

getValue

public <O> O getValue(Class<O> clazz)
Description copied from interface: AutowiredPropertyContainer
Returns the value of the property which can be assigned as value to the given Class type. If there are multiple properties available with fitting types null is returned.

Specified by:
getValue in interface AutowiredPropertyContainer
Returns:

iterator

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


Copyright © 2011. All Rights Reserved.