org.apache.commons.clazz.reflect.extended
Class ReflectedMap
java.lang.Object
java.util.AbstractMap
org.apache.commons.clazz.reflect.extended.ReflectedMap
- All Implemented Interfaces:
- Map
public class ReflectedMap
- extends AbstractMap
This is an implementation of the Map
interface
that is based on a Mapped property. Whenever possible, it
uses concrete methods on the owner of the property to manipulate the map.
Consider the following example:
Map map = (Map)clazz.getProperty("fooMap").get(instance);
Object value = map.get("bar");
If instance
has a getFoo(String key)
method,
this code will implicitly invoke it like this: getFoo("bar")
.
otherwise it will obtain the whole map and extract the
requested value.
- Version:
- $Id: ReflectedMap.java 155436 2005-02-26 13:17:48Z dirkv $
- Author:
- Dmitri Plotnikov
ReflectedMap
public ReflectedMap(Object instance,
ReflectedMappedProperty property)
- Constructor for ReflectedMap.
getPropertyValue
public Map getPropertyValue()
setPropertyValue
public void setPropertyValue(Map value)
getPropertyKeySet
public Set getPropertyKeySet()
get
public Object get(Object key)
- If there is a getFoo(key) method, calls that for every key.
Otherwise, calls getFooMap().get(key)
- Specified by:
get
in interface Map
- Overrides:
get
in class AbstractMap
- See Also:
Map.get(java.lang.Object)
size
public int size()
- Specified by:
size
in interface Map
- Overrides:
size
in class AbstractMap
- See Also:
Map.size()
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interface Map
- Overrides:
isEmpty
in class AbstractMap
- See Also:
Map.isEmpty()
keySet
public Set keySet()
- Specified by:
keySet
in interface Map
- Overrides:
keySet
in class AbstractMap
- See Also:
Map.keySet()
entrySet
public Set entrySet()
- Specified by:
entrySet
in interface Map
- Specified by:
entrySet
in class AbstractMap
- See Also:
Map.entrySet()
put
public Object put(Object key,
Object value)
- Specified by:
put
in interface Map
- Overrides:
put
in class AbstractMap
- See Also:
Map.put(java.lang.Object, java.lang.Object)
remove
public Object remove(Object key)
- Specified by:
remove
in interface Map
- Overrides:
remove
in class AbstractMap
- See Also:
Map.remove(java.lang.Object)
Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.