public final class BeanTools extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
BeanTools.AccessType
Access type
|
| Modifier and Type | Method and Description |
|---|---|
static String |
beanListToString(List<? extends Object> beansList,
BeanTools.AccessType accessType,
String... pathsToProperties)
Display a list of beans by listing the specified properties (bean separated by "\n", properties by ", ")
|
static String |
beanListToString(List<? extends Object> beansList,
String delimiterBeans,
String delimiterProperties,
BeanTools.AccessType accessType,
String... pathsToProperties)
Display a list of beans by listing the specified properties
|
static <T> Comparator<T> |
createPropertyComparator(String propertyExpression)
Wrapping of Apache communs BeanComparator.
|
static <T> Comparator<T> |
createPropertyComparator(String propertyExpression,
Comparator<T> comparator)
Wrapping of Apache communs BeanComparator to avoid "unchecked" tag in code.
|
static boolean |
equals(Object thiz,
Object obj,
BeanTools.AccessType accessType,
String... properties)
Equals method
|
static boolean |
equals(Object thiz,
Object obj,
Field... fields)
Equals method
|
static Field |
getAnnotatedPrivateField(Class<?> clazz,
Class<? extends Annotation>... annotations)
Retrieve an annotated from private field or from inherited private, protected or public field
|
static Field |
getAnnotatedPublicField(Class<?> clazz,
Class<? extends Annotation>... annotations)
Retrieve an annotated public field
|
static Field |
getAnnotatedPublicField(Object thiz,
Class<? extends Annotation>... annotations)
Retrieve an annotated public field or from inherited public field too
|
static <A extends Annotation> |
getAnnotationOnProperty(Class<?> beanClass,
Class<A> annotation,
String property)
Get an annotation on a bean property
|
static Object |
getValue(Object bean,
BeanTools.AccessType accessType,
String property)
Get a property value for a specified bean
|
static Object |
getValueFromPath(Object bean,
BeanTools.AccessType accessType,
String pathToProperty)
Get a property value for a specified bean
|
static int |
hashCode(Object thiz,
Field... fields)
HashCode method
|
static int |
hashCode(Object thiz,
Object... ids)
HashCode method
|
static <A extends Annotation> |
isAnnotationOnProperty(Class<?> beanClass,
Class<A> annotation,
String property)
Is there an annotation on a bean property
|
static String |
toString(Object bean,
BeanTools.AccessType accessType,
String... properties)
Display a bean by listing the specified properties (separated by "\n")
|
static String |
toString(Object bean,
String delimiter,
BeanTools.AccessType accessType,
String... pathsToProperties)
Display a bean by listing the specified properties
|
public static boolean equals(Object thiz, Object obj, BeanTools.AccessType accessType, String... properties)
thiz - First object ("this", not null)obj - Second objectaccessType - Access typeproperties - Properties (names) to checkpublic static boolean equals(Object thiz, Object obj, Field... fields)
thiz - First object ("this", not null)obj - Second objectfields - Public fields to check@SafeVarargs public static Field getAnnotatedPublicField(Object thiz, Class<? extends Annotation>... annotations) throws NoSuchFieldException
thiz - Objectannotations - Annotations to retrieve on a public fieldNoSuchFieldException - If an annotation cannot be found@SafeVarargs public static Field getAnnotatedPrivateField(Class<?> clazz, Class<? extends Annotation>... annotations) throws NoSuchFieldException
clazz - The class which contains annotations (or inherited class)annotations - Annotations to retrieveNoSuchFieldException - If an annotation cannot be found@SafeVarargs public static Field getAnnotatedPublicField(Class<?> clazz, Class<? extends Annotation>... annotations) throws NoSuchFieldException
clazz - The class which contains annotationsannotations - Annotations to retrieve on a public fieldNoSuchFieldException - If an annotation cannot be foundpublic static <A extends Annotation> A getAnnotationOnProperty(Class<?> beanClass, Class<A> annotation, String property) throws NoSuchFieldException
A - Annotation classbeanClass - Bean classannotation - Annotationproperty - Property nameNoSuchFieldException - If the property does not existpublic static Object getValue(Object bean, BeanTools.AccessType accessType, String property)
bean - BeanaccessType - Access typeproperty - Property namepublic static Object getValueFromPath(Object bean, BeanTools.AccessType accessType, String pathToProperty)
bean - BeanaccessType - Access typepathToProperty - properties path to access the property, example : beanX.beanY.propZpublic static int hashCode(Object thiz, Field... fields)
thiz - Bean (not null)fields - Public fields to considerepublic static int hashCode(Object thiz, Object... ids)
thiz - Bean (not null)ids - Bean IDspublic static <A extends Annotation> boolean isAnnotationOnProperty(Class<?> beanClass, Class<A> annotation, String property) throws NoSuchFieldException
A - Annotation classbeanClass - Bean classannotation - Annotationproperty - Property nameNoSuchFieldException - If the property does not existpublic static String toString(Object bean, String delimiter, BeanTools.AccessType accessType, String... pathsToProperties)
bean - Beandelimiter - Delimiter between properties in the resulting stringaccessType - Access typepathsToProperties - Path of properties to displaypublic static String toString(Object bean, BeanTools.AccessType accessType, String... properties)
bean - BeanaccessType - Access typeproperties - Properties to displaypublic static String beanListToString(List<? extends Object> beansList, BeanTools.AccessType accessType, String... pathsToProperties)
beansList - The beans list to browsedaccessType - Access typepathsToProperties - Paths to properties to displaypublic static String beanListToString(List<? extends Object> beansList, String delimiterBeans, String delimiterProperties, BeanTools.AccessType accessType, String... pathsToProperties)
beansList - The beans list to browseddelimiterBeans - Delimiter between beans in the resulting stringdelimiterProperties - Delimiter between properties in the resulting stringaccessType - Access typepathsToProperties - Paths to properties to displaypublic static <T> Comparator<T> createPropertyComparator(String propertyExpression)
T - generic typepropertyExpression - propertyExpressionpublic static <T> Comparator<T> createPropertyComparator(String propertyExpression, Comparator<T> comparator)
T - generic typepropertyExpression - PropertyExpressioncomparator - BeanComparator will pass the values of the specified bean property to this Comparator. If your
bean property is not a comparable or contains null values, a suitable comparator may be supplied in this
constructorCopyright © 2009-2013 IRD. All Rights Reserved.