public class Extractors extends Object
The methods in this class are for the most part simple factory methods for
various ValueExtractor
classes, but in some cases provide additional type
safety. They also tend to make the code more readable, especially if imported
statically, so their use is strongly encouraged in lieu of direct construction
of Extractor
classes.
Constructor and Description |
---|
Extractors() |
Modifier and Type | Method and Description |
---|---|
static <T,R> ValueExtractor<T,R> |
chained(String... fields)
Returns an extractor that extracts the specified fields
where extraction occurs in a chain where the result of each
field extraction is the input to the next extractor.
|
static <T,R> ValueExtractor<T,R> |
chained(ValueExtractor<?,?>... extractors)
Returns an extractor that extracts the specified fields
where extraction occurs in a chain where the result of each
field extraction is the input to the next extractor.
|
static <T,E> ValueExtractor<T,E> |
extract(String from)
Returns an extractor that extracts the value of the specified field.
|
static <T,E> ValueExtractor<T,E> |
extract(String from,
Object... aoParam)
Returns an extractor that extracts the value of the specified field.
|
static <T,E> ValueExtractor<T,E> |
fromPof(Class<E> cls,
int... indexes)
Returns an extractor that extracts the value of the specified index(es)
from a POF encoded binary value.
|
static <T,E> ValueExtractor<T,E> |
fromPof(Class<E> cls,
PofNavigator navigator)
Returns an extractor that extracts the value of the specified index(es)
from a POF encoded binary value.
|
static <T> ValueExtractor<T,?> |
fromPof(int... indexes)
Returns an extractor that extracts the value of the specified index(es)
from a POF encoded binary value.
|
static <T> ValueExtractor<T,T> |
identity()
Returns an extractor that always returns its input argument.
|
static <T,E> ValueExtractor<T,E> |
identityCast()
Returns an extractor that casts its input argument.
|
static <T> ValueExtractor<T,List<?>> |
multi(String... fields)
Returns an extractor that extracts the specified fields
and returns the extracted values in a
List . |
static <T> ValueExtractor<T,List<?>> |
multi(ValueExtractor<T,?>... extractors)
Returns an extractor that extracts values using the specified
ValueExtractor s and returns the extracted values in a List . |
public static <T> ValueExtractor<T,T> identity()
T
- the type of the input and output objects to the functionpublic static <T,E> ValueExtractor<T,E> extract(String from)
T
- the type of the object to extract fromE
- the type of the extracted valuefrom
- the name of the field or method to extract the value fromUniversalExtractor
public static <T,E> ValueExtractor<T,E> extract(String from, Object... aoParam)
T
- the type of the object to extract fromE
- the type of the extracted valuefrom
- the name of the method to extract the value from (which must be
the full method name)aoParam
- the parameters to pass to the methodUniversalExtractor
public static <T> ValueExtractor<T,List<?>> multi(String... fields)
List
.T
- the type of the object to extract fromfields
- the field names to extractIllegalArgumentException
- if the fields parameter is null or an
empty arrayUniversalExtractor
public static <T> ValueExtractor<T,List<?>> multi(ValueExtractor<T,?>... extractors)
ValueExtractor
s and returns the extracted values in a List
.T
- the type of the object to extract fromextractors
- the ValueExtractor
s to use to extract the list of valuesIllegalArgumentException
- if the fields parameter is null or an
empty arrayUniversalExtractor
public static <T,R> ValueExtractor<T,R> chained(String... fields)
T
- the type of the object to extract fromfields
- the field names to extract (if any field name contains a dot '.'
that field name is split into multiple field names delimiting on
the dots.IllegalArgumentException
- if the fields parameter is null or an
empty arrayUniversalExtractor
public static <T,R> ValueExtractor<T,R> chained(ValueExtractor<?,?>... extractors)
T
- the type of the object to extract fromextractors
- the ValueExtractor
s to use to extract the list of valuesIllegalArgumentException
- if the extractors parameter is null or an
empty arrayUniversalExtractor
public static <T,E> ValueExtractor<T,E> identityCast()
T
- the type of the input objects to the functionE
- the type of the output objects to the functionpublic static <T> ValueExtractor<T,?> fromPof(int... indexes)
T
- the type of the object to extract fromindexes
- the POF index(es) to extractpublic static <T,E> ValueExtractor<T,E> fromPof(Class<E> cls, int... indexes)
T
- the type of the POF serialized object to extract fromE
- the type of the extracted valueindexes
- the POF index(es) to extractNullPointerException
- if the indexes parameter is nullpublic static <T,E> ValueExtractor<T,E> fromPof(Class<E> cls, PofNavigator navigator)
T
- the type of the POF serialized object to extract fromE
- the type of the extracted valuenavigator
- the PofNavigator
to use to determine the POF path to extractNullPointerException
- if the indexes parameter is null