public class PropertySupport
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static PropertySupport |
INSTANCE |
private static java.lang.String |
SEPARATOR |
| Constructor and Description |
|---|
PropertySupport() |
| Modifier and Type | Method and Description |
|---|---|
static PropertySupport |
instance()
Returns the singleton instance of this class.
|
private boolean |
isNestedProperty(java.lang.String propertyName) |
private java.lang.String |
nextPropertyNameFrom(java.lang.String propertyNameChain) |
private java.lang.String |
popPropertyNameFrom(java.lang.String propertyNameChain) |
<T> T |
propertyValue(java.lang.String propertyName,
java.lang.Class<T> clazz,
java.lang.Object target)
Return the value of a simple property from a target object.
|
<T> T |
propertyValueOf(java.lang.String propertyName,
java.lang.Class<T> clazz,
java.lang.Object target)
Returns the value of the given property name given target.
|
static <T> T |
propertyValueOf(java.lang.String propertyName,
java.lang.Object target,
java.lang.Class<T> clazz)
Static variant of
propertyValueOf(String, Class, Object) for syntactic sugar. |
<T> java.util.List<T> |
propertyValues(java.lang.String propertyName,
java.lang.Class<T> clazz,
java.lang.Iterable<?> target)
Returns a
containing the values of the given property name, from the elements of the
given . |
java.util.List<java.lang.Object> |
propertyValues(java.lang.String fieldOrPropertyName,
java.lang.Iterable<?> target)
Returns a
containing the values of the given property name, from the elements of the
given . |
boolean |
publicGetterExistsFor(java.lang.String fieldName,
java.lang.Object actual) |
private <T> java.util.List<T> |
simplePropertyValues(java.lang.String propertyName,
java.lang.Class<T> clazz,
java.lang.Iterable<?> target) |
private static final java.lang.String SEPARATOR
private static final PropertySupport INSTANCE
public static PropertySupport instance()
public <T> java.util.List<T> propertyValues(java.lang.String propertyName,
java.lang.Class<T> clazz,
java.lang.Iterable<?> target)
List containing the values of the given property name, from the elements of the
given Iterable. If the given Iterable is empty or null, this method will
return an empty List. This method supports nested properties (e.g. "address.street.number").T - the type of the extracted elements.propertyName - the name of the property. It may be a nested property. It is left to the clients to validate
for null or empty.clazz - type of propertytarget - the given Iterable.Iterable containing the values of the given property name, from the elements of the given
Iterable.IntrospectionError - if an element in the given Iterable does not have a property with a matching
name.public static <T> T propertyValueOf(java.lang.String propertyName,
java.lang.Object target,
java.lang.Class<T> clazz)
propertyValueOf(String, Class, Object) for syntactic sugar.T - the type of the extracted elements.propertyName - the name of the property. It may be a nested property. It is left to the clients to validate
for null or empty.target - the given objectclazz - type of propertyIntrospectionError - if the given target does not have a property with a matching name.private <T> java.util.List<T> simplePropertyValues(java.lang.String propertyName,
java.lang.Class<T> clazz,
java.lang.Iterable<?> target)
private java.lang.String popPropertyNameFrom(java.lang.String propertyNameChain)
private java.lang.String nextPropertyNameFrom(java.lang.String propertyNameChain)
private boolean isNestedProperty(java.lang.String propertyName)
public <T> T propertyValue(java.lang.String propertyName,
java.lang.Class<T> clazz,
java.lang.Object target)
This only works for simple property, nested property are not supported ! use
propertyValueOf(String, Class, Object)
T - the type of the extracted value.propertyName - the name of the property. It may be a nested property. It is left to the clients to validate
for null or empty.target - the given objectclazz - type of propertyIntrospectionError - if the given target does not have a property with a matching name.public <T> T propertyValueOf(java.lang.String propertyName,
java.lang.Class<T> clazz,
java.lang.Object target)
null, this method will
return null.T - the type of the extracted value.propertyName - the name of the property. It may be a nested property. It is left to the clients to validate
for null or empty.clazz - the class of property.target - the given Object to extract property from.IntrospectionError - if target object does not have a property with a matching name.java.lang.IllegalArgumentException - if propertyName is null.public java.util.List<java.lang.Object> propertyValues(java.lang.String fieldOrPropertyName,
java.lang.Iterable<?> target)
List containing the values of the given property name, from the elements of the
given Iterable. If the given Iterable is empty or null, this method will
return an empty List. This method supports nested properties (e.g. "address.street.number").fieldOrPropertyName - the name of the property. It may be a nested property. It is left to the clients to validate
for null or empty.target - the given Iterable.Iterable containing the values of the given property name, from the elements of the given
Iterable.IntrospectionError - if an element in the given Iterable does not have a property with a matching
name.public boolean publicGetterExistsFor(java.lang.String fieldName,
java.lang.Object actual)