Top Description Inners Constructors Methods
org.springframework.core.annotation

public abstract Class MergedAnnotationPredicates

extends Object
Class Inheritance
Imports
java.lang.annotation.Annotation, java.util.Collection, .HashSet, .Set, java.util.function.Function, .Predicate, org.springframework.lang.Nullable, org.springframework.util.Assert, .ObjectUtils

Predicate implementations that provide various test operations for MergedAnnotations.
Author
Phillip Webb
Since
5.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <A extends Annotation> Predicate<MergedAnnotation<A>>

Returns:

a Predicate that matches the first run of the extracted values
firstRunOf
(Function<? super MergedAnnotation<A>, ?>
function used to extract the value to check
valueExtractor
)

Create a new stateful, single use Predicate that matches only the first run of an extracted value.

public static <
the annotation type
A extends Annotation
>
Predicate<MergedAnnotation<? extends A>>

Returns:

a Predicate to test the annotation type
typeIn
(String...
the names that should be matched
typeNames
)

Create a new Predicate that evaluates to true if the name of the merged annotation type is contained in the specified array.

public static <
the annotation type
A extends Annotation
>
Predicate<MergedAnnotation<? extends A>>

Returns:

a Predicate to test the annotation type
typeIn
(Class<?>...
the types that should be matched
types
)

Create a new Predicate that evaluates to true if the merged annotation type is contained in the specified array.

public static <
the annotation type
A extends Annotation
>
Predicate<MergedAnnotation<? extends A>>

Returns:

a Predicate to test the annotation type
typeIn
(Collection<?>
the type names or classes that should be matched
types
)

Create a new Predicate that evaluates to true if the merged annotation type is contained in the specified collection.

public static <A extends Annotation, K> Predicate<MergedAnnotation<A>>

Returns:

a Predicate that matches a unique annotation based on the extracted key
unique
(Function<? super MergedAnnotation<A>, K>
function used to extract the key used to test for uniqueness
keyExtractor
)

Create a new stateful, single use Predicate that matches annotations that are unique based on the extracted key.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MergedAnnotationPredicatesback to summary
private MergedAnnotationPredicates()

Method Detail

firstRunOfback to summary
public static <A extends Annotation> Predicate<MergedAnnotation<A>> firstRunOf(Function<? super MergedAnnotation<A>, ?> valueExtractor)

Create a new stateful, single use 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.

Parameters
valueExtractor:Function<? super MergedAnnotation<A>, ?>

function used to extract the value to check

Returns:Predicate<MergedAnnotation<A>>

a Predicate that matches the first run of the extracted values

typeInback to summary
public static <A extends Annotation> Predicate<MergedAnnotation<? extends A>> 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.

Parameters
<A>
the annotation type
typeNames:String[]

the names that should be matched

Returns:Predicate<MergedAnnotation<? extends A>>

a Predicate to test the annotation type

typeInback to summary
public static <A extends Annotation> Predicate<MergedAnnotation<? extends A>> typeIn(Class<?>... types)

Create a new Predicate that evaluates to true if the merged annotation type is contained in the specified array.

Parameters
<A>
the annotation type
types:Class<?>[]

the types that should be matched

Returns:Predicate<MergedAnnotation<? extends A>>

a Predicate to test the annotation type

typeInback to summary
public static <A extends Annotation> Predicate<MergedAnnotation<? extends A>> typeIn(Collection<?> types)

Create a new Predicate that evaluates to true if the merged annotation type is contained in the specified collection.

Parameters
<A>
the annotation type
types:Collection<?>

the type names or classes that should be matched

Returns:Predicate<MergedAnnotation<? extends A>>

a Predicate to test the annotation type

uniqueback to summary
public static <A extends Annotation, K> Predicate<MergedAnnotation<A>> 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. For example MergedAnnotationPredicates.unique(MergedAnnotation::getType) will match the first time a unique type is encountered.

Parameters
keyExtractor:Function<? super MergedAnnotation<A>, K>

function used to extract the key used to test for uniqueness

Returns:Predicate<MergedAnnotation<A>>

a Predicate that matches a unique annotation based on the extracted key

org.springframework.core.annotation back to summary

private Class MergedAnnotationPredicates.FirstRunOfPredicate<A extends java.lang.annotation.Annotation>

extends Object
implements Predicate<MergedAnnotation<A extends Annotation>>
Class Inheritance
  • java.lang.Object
  • org.springframework.core.annotation.MergedAnnotationPredicates.FirstRunOfPredicate
All Implemented Interfaces
java.util.function.Predicate

Predicate implementation used for MergedAnnotationPredicates#firstRunOf(Function).

Field Summary

Modifier and TypeField and Description
private boolean
private Object
private final Function<? super MergedAnnotation<A>, ?>

Constructor Summary

AccessConstructor and Description
pack-priv
FirstRunOfPredicate(Function<? super MergedAnnotation<A>, ?> valueExtractor)

Method Summary

Modifier and TypeMethod and Description
public boolean
test(MergedAnnotation<A>
the input argument
annotation
)

Implements java.util.function.Predicate.test.

Evaluates this predicate on the given argument.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hasLastValueback to summary
private boolean hasLastValue
lastValueback to summary
private Object lastValue
Annotations
@Nullable
valueExtractorback to summary
private final Function<? super MergedAnnotation<A>, ?> valueExtractor

Constructor Detail

FirstRunOfPredicateback to summary
pack-priv FirstRunOfPredicate(Function<? super MergedAnnotation<A>, ?> valueExtractor)

Method Detail

testback to summary
public boolean test(MergedAnnotation<A> annotation)

Implements java.util.function.Predicate.test.

Doc from java.util.function.Predicate.test.

Evaluates this predicate on the given argument.

Parameters
annotation:MergedAnnotation<A>

the input argument

Returns:boolean

true if the input argument matches the predicate, otherwise false

Annotations
@Override
org.springframework.core.annotation back to summary

private Class MergedAnnotationPredicates.UniquePredicate<A extends java.lang.annotation.Annotation, K>

extends Object
implements Predicate<MergedAnnotation<A extends Annotation>>
Class Inheritance
  • java.lang.Object
  • org.springframework.core.annotation.MergedAnnotationPredicates.UniquePredicate
All Implemented Interfaces
java.util.function.Predicate

Predicate implementation used for MergedAnnotationPredicates#unique(Function).

Field Summary

Modifier and TypeField and Description
private final Function<? super MergedAnnotation<A>, K>
private final Set<K>

Constructor Summary

AccessConstructor and Description
pack-priv
UniquePredicate(Function<? super MergedAnnotation<A>, K> keyExtractor)

Method Summary

Modifier and TypeMethod and Description
public boolean
test(MergedAnnotation<A>
the input argument
annotation
)

Implements java.util.function.Predicate.test.

Evaluates this predicate on the given argument.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyExtractorback to summary
private final Function<? super MergedAnnotation<A>, K> keyExtractor
seenback to summary
private final Set<K> seen

Constructor Detail

UniquePredicateback to summary
pack-priv UniquePredicate(Function<? super MergedAnnotation<A>, K> keyExtractor)

Method Detail

testback to summary
public boolean test(MergedAnnotation<A> annotation)

Implements java.util.function.Predicate.test.

Doc from java.util.function.Predicate.test.

Evaluates this predicate on the given argument.

Parameters
annotation:MergedAnnotation<A>

the input argument

Returns:boolean

true if the input argument matches the predicate, otherwise false

Annotations
@Override