public class ValueUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.Map |
dynamicPropertyHandlerMap |
private static int |
UNKNOWN_LENGTH_MAX_COUNT |
Constructor and Description |
---|
ValueUtils() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.Object |
convert(java.lang.Object value,
java.lang.Class type)
Convert value to type.
|
static java.lang.Object |
expandCollection(java.lang.Object collection,
int size)
Grows the collection if necessary to the specified size.
|
static java.lang.reflect.Method |
getAccessibleMethod(java.lang.reflect.Method method)
Return an accessible method (that is, one that can be invoked via
reflection) that implements the specified Method.
|
private static java.lang.reflect.Method |
getAccessibleMethodFromInterfaceNest(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] parameterTypes)
Return an accessible method (that is, one that can be invoked via
reflection) that implements the specified method, by scanning through
all implemented interfaces and subinterfaces.
|
static int |
getCollectionHint(java.lang.Class clazz)
Returns 1 if the type is a collection,
-1 if it is definitely not
and 0 if it may be a collection in some cases.
|
static DynamicPropertyHandler |
getDynamicPropertyHandler(java.lang.Class clazz)
Returns a shared instance of the dynamic property handler class
returned by
getDynamicPropertyHandlerClass() . |
static int |
getIndexedPropertyLength(java.lang.Object object,
java.beans.IndexedPropertyDescriptor pd)
If there is a regular non-indexed read method for this property,
uses this method to obtain the collection and then returns its
length.
|
static int |
getLength(java.lang.Object collection)
Returns the length of the supplied collection.
|
static java.lang.Object |
getValue(java.lang.Object object)
If the parameter is a container, opens the container and
return the contents.
|
static java.lang.Object |
getValue(java.lang.Object collection,
int index)
Returns the index'th element of the supplied collection.
|
static java.lang.Object |
getValue(java.lang.Object bean,
java.beans.PropertyDescriptor propertyDescriptor)
Returns the value of the bean's property represented by
the supplied property descriptor.
|
static java.lang.Object |
getValue(java.lang.Object bean,
java.beans.PropertyDescriptor propertyDescriptor,
int index)
Returns the index'th element of the bean's property represented by
the supplied property descriptor.
|
static boolean |
isCollection(java.lang.Object value)
Returns true if the object is an array or a Collection.
|
static java.util.Iterator |
iterate(java.lang.Object collection)
Returns an iterator for the supplied collection.
|
static java.lang.Object |
remove(java.lang.Object collection,
int index)
Remove the index'th element from the supplied collection.
|
static void |
setValue(java.lang.Object collection,
int index,
java.lang.Object value)
Modifies the index'th element of the supplied collection.
|
static void |
setValue(java.lang.Object bean,
java.beans.PropertyDescriptor propertyDescriptor,
int index,
java.lang.Object value)
Modifies the index'th element of the bean's property represented by
the supplied property descriptor.
|
static void |
setValue(java.lang.Object bean,
java.beans.PropertyDescriptor propertyDescriptor,
java.lang.Object value)
Modifies the value of the bean's property represented by
the supplied property descriptor.
|
private static java.util.Map dynamicPropertyHandlerMap
private static final int UNKNOWN_LENGTH_MAX_COUNT
public static boolean isCollection(java.lang.Object value)
value
- to testpublic static int getCollectionHint(java.lang.Class clazz)
clazz
- to testpublic static int getIndexedPropertyLength(java.lang.Object object, java.beans.IndexedPropertyDescriptor pd)
object
- collectionpd
- IndexedPropertyDescriptorpublic static int getLength(java.lang.Object collection)
collection
- to checkpublic static java.util.Iterator iterate(java.lang.Object collection)
collection
- to iteratepublic static java.lang.Object expandCollection(java.lang.Object collection, int size)
collection
- to expandsize
- desired sizepublic static java.lang.Object remove(java.lang.Object collection, int index)
collection
- to editindex
- intpublic static java.lang.Object getValue(java.lang.Object collection, int index)
collection
- to readindex
- intpublic static void setValue(java.lang.Object collection, int index, java.lang.Object value)
collection
- to editindex
- to replacevalue
- new valuepublic static java.lang.Object getValue(java.lang.Object bean, java.beans.PropertyDescriptor propertyDescriptor)
bean
- to readpropertyDescriptor
- indicating what to readpublic static void setValue(java.lang.Object bean, java.beans.PropertyDescriptor propertyDescriptor, java.lang.Object value)
bean
- to readpropertyDescriptor
- indicating what to readvalue
- to setprivate static java.lang.Object convert(java.lang.Object value, java.lang.Class type)
value
- Objecttype
- destinationpublic static java.lang.Object getValue(java.lang.Object bean, java.beans.PropertyDescriptor propertyDescriptor, int index)
bean
- to readpropertyDescriptor
- indicating what to readindex
- intpublic static void setValue(java.lang.Object bean, java.beans.PropertyDescriptor propertyDescriptor, int index, java.lang.Object value)
bean
- to editpropertyDescriptor
- indicating what to setindex
- intvalue
- to setpublic static java.lang.Object getValue(java.lang.Object object)
object
- to readpublic static DynamicPropertyHandler getDynamicPropertyHandler(java.lang.Class clazz)
getDynamicPropertyHandlerClass()
.clazz
- to handlepublic static java.lang.reflect.Method getAccessibleMethod(java.lang.reflect.Method method)
null
.method
- The method that we wish to callprivate static java.lang.reflect.Method getAccessibleMethodFromInterfaceNest(java.lang.Class clazz, java.lang.String methodName, java.lang.Class[] parameterTypes)
null
.clazz
- Parent class for the interfaces to be checkedmethodName
- Method name of the method we wish to callparameterTypes
- The parameter type signatures