public final class PropertyUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T extends Annotation> |
getAnnotationForProperty(Class cls,
String name,
Class<T> anno) |
static Object |
getDotProperty(Object target,
String propertyName) |
static Method |
getGetter(Object target,
String propertyName) |
static Map<String,Object> |
getProperties(Object target,
Class<? extends Annotation>... excludeAnnotations)
Build a map of direct javabeans properties of the target object.
|
static Object |
getProperty(Object target,
String propertyName)
Get a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.
|
static List<String> |
getPropertyNames(Class clazz) |
static Object |
getPropertyOrMappedValue(Object target,
String propertyName) |
static Boolean |
isReadable(Object obj,
String name) |
static Boolean |
isWriteable(Object target,
String propertyName) |
static String |
propertiesToString(Object obj)
Return a comma-separated String of r/w properties of the specified object.
|
static boolean |
propertyHasAnnotation(Class cls,
String name,
Class<? extends Annotation> anno) |
static void |
resetCache() |
static void |
setProperties(Object target,
Map properties)
Set a
Map of direct or indirect properties on the target object. |
static void |
setProperty(Object target,
String propertyName,
Object propertyValue)
Set a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.
|
static Object |
transform(Object value,
Class destinationClass)
Try to transform the passed in value into the destinationClass, via a applying a boatload of
heuristics.
|
public static void resetCache()
public static void setProperty(Object target, String propertyName, Object propertyValue) throws PropertyException
target
- the target object on which to set the property.propertyName
- the name of the property to set.propertyValue
- the value of the property to set.PropertyException
- if an error happened while trying to set the property.public static Map<String,Object> getProperties(Object target, Class<? extends Annotation>... excludeAnnotations) throws PropertyException
target
- the target object from which to get properties names.PropertyException
- if an error happened while trying to get a property.public static List<String> getPropertyNames(Class clazz) throws PropertyException
PropertyException
public static boolean propertyHasAnnotation(Class cls, String name, Class<? extends Annotation> anno)
public static <T extends Annotation> T getAnnotationForProperty(Class cls, String name, Class<T> anno)
public static Boolean isReadable(Object obj, String name)
public static Boolean isWriteable(Object target, String propertyName)
public static Object getProperty(Object target, String propertyName) throws PropertyException
target
- the target object from which to get the property.propertyName
- the name of the property to get.PropertyException
- if an error happened while trying to get the property.public static Object getDotProperty(Object target, String propertyName) throws PropertyException
PropertyException
public static Object getPropertyOrMappedValue(Object target, String propertyName) throws PropertyException
PropertyException
public static void setProperties(Object target, Map properties) throws PropertyException
Map
of direct or indirect properties on the target object.target
- the target object on which to set the properties.properties
- a Map
of String/Object pairs.PropertyException
- if an error happened while trying to set a property.public static String propertiesToString(Object obj)
obj
- the object to introspect.public static Object transform(Object value, Class destinationClass)
value
- destinationClass
- Copyright © 2016. All rights reserved.