public abstract class MergedAnnotationPredicates extends Object
MergedAnnotations
.Modifier and Type | Method and Description |
---|---|
static <A extends Annotation> |
firstRunOf(Function<? super MergedAnnotation<A>,?> valueExtractor)
Create a new stateful, single use
Predicate that matches only
the first run of an extracted value. |
static <A extends Annotation> |
typeIn(Class<?>... types)
Create a new
Predicate that evaluates to true if the
merged annotation type is contained in
the specified array. |
static <A extends Annotation> |
typeIn(Collection<?> types)
Create a new
Predicate that evaluates to true if the
merged annotation type is contained in
the specified collection. |
static <A extends Annotation> |
typeIn(String... typeNames)
Create a new
Predicate that evaluates to true if the name of the
merged annotation type is contained in
the specified array. |
static <A extends Annotation,K> |
unique(Function<? super MergedAnnotation<A>,K> keyExtractor)
Create a new stateful, single use
Predicate that matches
annotations that are unique based on the extracted key. |
public static <A extends Annotation> Predicate<MergedAnnotation<? extends A>> typeIn(String... typeNames)
Predicate
that evaluates to true
if the name of the
merged annotation type is contained in
the specified array.A
- the annotation typetypeNames
- the names that should be matchedPredicate
to test the annotation typepublic static <A extends Annotation> Predicate<MergedAnnotation<? extends A>> typeIn(Class<?>... types)
Predicate
that evaluates to true
if the
merged annotation type is contained in
the specified array.A
- the annotation typetypes
- the types that should be matchedPredicate
to test the annotation typepublic static <A extends Annotation> Predicate<MergedAnnotation<? extends A>> typeIn(Collection<?> types)
Predicate
that evaluates to true
if the
merged annotation type is contained in
the specified collection.A
- the annotation typetypes
- the type names or classes that should be matchedPredicate
to test the annotation typepublic static <A extends Annotation> Predicate<MergedAnnotation<A>> firstRunOf(Function<? super MergedAnnotation<A>,?> valueExtractor)
Predicate
that matches only
the first run of an extracted value. For example,
MergedAnnotationPredicates.firstRunOf(MergedAnnotation::distance)
will match the first annotation, and any subsequent runs that have the
same distance.
NOTE: This predicate only matches the first run. Once the extracted
value changes, the predicate always returns false
. For example,
if you have a set of annotations with distances [1, 1, 2, 1]
then
only the first two will match.
valueExtractor
- function used to extract the value to checkPredicate
that matches the first run of the extracted
valuespublic static <A extends Annotation,K> Predicate<MergedAnnotation<A>> unique(Function<? super MergedAnnotation<A>,K> keyExtractor)
Predicate
that matches
annotations that are unique based on the extracted key. For example
MergedAnnotationPredicates.unique(MergedAnnotation::getType)
will
match the first time a unique type is encountered.keyExtractor
- function used to extract the key used to test for
uniquenessPredicate
that matches a unique annotation based on the
extracted key