public class BeanAdapter extends AbstractMap<String,Object>
Map interface.
A call to Map.get(Object) invokes the getter for the corresponding
property, and a call to Map.put(Object, Object) invokes the
property's setter. Appending a "Property" suffix to the key returns the
corresponding property model.AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Modifier and Type | Field and Description |
|---|---|
static String |
GET_PREFIX |
static String |
IS_PREFIX |
static String |
PROPERTY_SUFFIX |
static String |
SET_PREFIX |
static String |
VALUE_OF_METHOD_NAME |
| Constructor and Description |
|---|
BeanAdapter(Object bean)
Creates a new Bean adapter.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
coerce(Object value,
Class<? extends T> type)
Coerces a value to a given type.
|
boolean |
containsKey(Object key)
Verifies the existence of a property.
|
Set<Map.Entry<String,Object>> |
entrySet() |
boolean |
equals(Object object) |
Object |
get(Object key)
Invokes the getter method for the given property.
|
static <T> T |
get(Object target,
Class<?> sourceType,
String key)
Invokes the static getter method for the given property.
|
Object |
getBean()
Returns the Bean object this adapter wraps.
|
static Object |
getConstantValue(Class<?> type,
String name)
Returns the value of a named constant.
|
static Type |
getGenericListItemType(Type listType)
Determines the type of a list item.
|
static Type |
getGenericMapValueType(Type mapType)
Determines the type of a map value.
|
static Type |
getGenericType(Class<?> sourceType,
String key,
Class<?> targetType)
Returns the generic type of a static property.
|
Type |
getGenericType(String key)
Returns the generic type of a property.
|
static Class<?> |
getListItemType(Type listType)
Determines the type of a list item.
|
static Class<?> |
getMapValueType(Type mapType)
Determines the type of a map value.
|
<T> ObservableValue<T> |
getPropertyModel(String key)
Returns the property model for the given property.
|
static Class<?> |
getType(Class<?> sourceType,
String key,
Class<?> targetType)
Returns the type of a static property.
|
Class<?> |
getType(String key)
Returns the type of a property.
|
int |
hashCode() |
static boolean |
isDefined(Class<?> sourceType,
String key,
Class<?> targetType)
Tests the existence of a static property.
|
boolean |
isReadOnly(String key)
Tests the mutability of a property.
|
static void |
put(Object target,
Class<?> sourceType,
String key,
Object value)
Invokes a static setter method for the given property.
|
Object |
put(String key,
Object value)
Invokes a setter method for the given property.
|
clear, clone, containsValue, isEmpty, keySet, putAll, remove, size, toString, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic static final String GET_PREFIX
public static final String IS_PREFIX
public static final String SET_PREFIX
public static final String PROPERTY_SUFFIX
public static final String VALUE_OF_METHOD_NAME
public BeanAdapter(Object bean)
bean - The Bean object to wrap.public Object getBean()
public Object put(String key, Object value)
coerce(Object, Class) method is used as needed to attempt to
convert a given value to the property type, as defined by the return
value of the getter method.put in interface Map<String,Object>put in class AbstractMap<String,Object>key - The property name.value - The new property value.PropertyNotFoundException - If the given property does not exist or is read-only.public boolean containsKey(Object key)
containsKey in interface Map<String,Object>containsKey in class AbstractMap<String,Object>key - The property name.public boolean isReadOnly(String key)
key - The property name.public <T> ObservableValue<T> getPropertyModel(String key)
key - The property name.public Class<?> getType(String key)
key - The property name.public Type getGenericType(String key)
key - The property name.public boolean equals(Object object)
public int hashCode()
public static <T> T coerce(Object value, Class<? extends T> type)
value - type - public static <T> T get(Object target, Class<?> sourceType, String key)
target - The object to which the property is attached.sourceType - The class that defines the property.key - The property name.public static void put(Object target, Class<?> sourceType, String key, Object value)
coerce(Object, Class) method is used to attempt to convert the
value to the actual property type (defined by the return value of the
getter method).target - The object to which the property is or will be attached.sourceType - The class that defines the property.key - The property name.value - The new property value.PropertyNotFoundException - If the given static property does not exist or is read-only.public static boolean isDefined(Class<?> sourceType, String key, Class<?> targetType)
sourceType - The class that defines the property.key - The property name.targetType - The type of the object to which the property applies.public static Class<?> getType(Class<?> sourceType, String key, Class<?> targetType)
sourceType - The class that defines the property.key - The property name.targetType - The type of the object to which the property applies.public static Type getGenericType(Class<?> sourceType, String key, Class<?> targetType)
sourceType - The class that defines the property.key - The property name.targetType - The type of the object to which the property applies.public static Class<?> getListItemType(Type listType)
listType - public static Class<?> getMapValueType(Type mapType)
mapType - public static Type getGenericListItemType(Type listType)
listType - public static Type getGenericMapValueType(Type mapType)
mapType - Copyright © 2025. All rights reserved.