Class BeanMap
java.lang.Object
org.springframework.cglib.beans.BeanMap
- All Implemented Interfaces:
Map
A
Map-based view of a JavaBean. The default set of keys is the
union of all property names (getters or setters). An attempt to set
a read-only property will be ignored, and write-only properties will
be returned as null. Removal of objects is not a
supported (the key set is fixed).- Author:
- Chris Nokleberg
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Objectstatic final intLimit the properties reflected in the key set of the map to readable properties.static final intLimit the properties reflected in the key set of the map to writable properties. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) static BeanMapHelper method to create a newBeanMap.entrySet()booleanabstract ObjectGet the property of a bean.getBean()Return the bean currently in use by this map.abstract ClassgetPropertyType(String name) Get the type of a property.inthashCode()booleanisEmpty()abstract BeanMapnewInstance(Object bean) Create a newBeanMapinstance using the specified bean.abstract ObjectSet the property of a bean.voidvoidChange the underlying bean this map should use.intsize()toString()values()Methods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
REQUIRE_GETTER
public static final int REQUIRE_GETTERLimit the properties reflected in the key set of the map to readable properties.- See Also:
-
REQUIRE_SETTER
public static final int REQUIRE_SETTERLimit the properties reflected in the key set of the map to writable properties.- See Also:
-
bean
-
-
Constructor Details
-
BeanMap
protected BeanMap() -
BeanMap
-
-
Method Details
-
create
-
newInstance
Create a newBeanMapinstance using the specified bean. This is faster than using thecreate(Object)static method.- Parameters:
bean- the JavaBean underlying the map- Returns:
- a new
BeanMapinstance
-
getPropertyType
-
get
-
put
-
get
Get the property of a bean. This allows aBeanMapto be used statically for multiple beans--the bean instance tied to the map is ignored and the bean passed to this method is used instead.- Parameters:
bean- the bean to query; must be compatible with the type of thisBeanMapkey- must be a String- Returns:
- the current value, or null if there is no matching property
-
put
Set the property of a bean. This allows aBeanMapto be used statically for multiple beans--the bean instance tied to the map is ignored and the bean passed to this method is used instead.- Parameters:
key- must be a String- Returns:
- the old value, if there was one, or null
-
setBean
Change the underlying bean this map should use.- Parameters:
bean- the new JavaBean- See Also:
-
getBean
Return the bean currently in use by this map.- Returns:
- the current JavaBean
- See Also:
-
clear
-
containsKey
- Specified by:
containsKeyin interfaceMap
-
containsValue
- Specified by:
containsValuein interfaceMap
-
size
-
isEmpty
-
remove
-
putAll
-
equals
-
hashCode
-
entrySet
-
values
-
toString
-