public class Properties<T>
extends java.lang.Object
Iterable
or array.Modifier and Type | Field and Description |
---|---|
(package private) java.lang.String |
propertyName |
(package private) PropertySupport |
propertySupport |
(package private) java.lang.Class<T> |
propertyType |
Constructor and Description |
---|
Properties(java.lang.String propertyName,
java.lang.Class<T> propertyType) |
Modifier and Type | Method and Description |
---|---|
private static void |
checkIsNotNullOrEmpty(java.lang.String propertyName) |
static Properties<java.lang.Object> |
extractProperty(java.lang.String propertyName)
Creates a new
. |
static <T> Properties<T> |
extractProperty(java.lang.String propertyName,
java.lang.Class<T> propertyType)
Creates a new
. |
java.util.List<T> |
from(java.lang.Iterable<?> c)
Extracts the values of the property (specified previously in
) from the elements
of the given . |
java.util.List<T> |
from(java.lang.Object[] array)
Extracts the values of the property (specified previously in
) from the elements
of the given array. |
<U> Properties<U> |
ofType(java.lang.Class<U> propertyType)
Specifies the target type of an instance that was previously created with
extractProperty(String) . |
final java.lang.String propertyName
final java.lang.Class<T> propertyType
PropertySupport propertySupport
Properties(java.lang.String propertyName, java.lang.Class<T> propertyType)
public static <T> Properties<T> extractProperty(java.lang.String propertyName, java.lang.Class<T> propertyType)
Properties
.T
- the type of value to extract.propertyName
- the name of the property to be read from the elements of a Iterable
. It may be a nested
property (e.g. "address.street.number").propertyType
- the type of property to extractProperties
.java.lang.NullPointerException
- if the given property name is null
.java.lang.IllegalArgumentException
- if the given property name is empty.public static Properties<java.lang.Object> extractProperty(java.lang.String propertyName)
Properties
with given propertyName and Object as property type.
.propertyName
- the name of the property to be read from the elements of a Iterable
. It may be a nested
property (e.g. "address.street.number").Properties
.java.lang.NullPointerException
- if the given property name is null
.java.lang.IllegalArgumentException
- if the given property name is empty.private static void checkIsNotNullOrEmpty(java.lang.String propertyName)
public <U> Properties<U> ofType(java.lang.Class<U> propertyType)
extractProperty(String)
.
This is so that you can write:
extractProperty("name").ofType(String.class).from(fellowshipOfTheRing);
instead of:
extractProperty("name", String.class).from(fellowshipOfTheRing);
U
- the type of value to extract.propertyType
- the type of property to extract.Properties
with the given type.public java.util.List<T> from(java.lang.Iterable<?> c)
extractProperty(String)
) from the elements
of the given Iterable
.c
- the given Iterable
.Iterable
.IntrospectionError
- if an element in the given Iterable
does not have a property with a matching name.public java.util.List<T> from(java.lang.Object[] array)
extractProperty(String)
) from the elements
of the given array.array
- the given array.IntrospectionError
- if an element in the given array does not have a property with a matching name.