Class Beans
java.lang.Object
org.microbean.bean.Beans
Utility methods for working with
Beans.- Author:
- Laird Nelson
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBeans(AnnotationMirror alternate, AnnotationMirror rank) Creates a newBeans.Creates a newBeans.Beans(Domain d, AnnotationMirror alternate, AnnotationMirror rank) Creates a newBeans. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanalternate(Collection<? extends AnnotationMirror> as) Returnstrueif and only if the suppliedCollectionofAnnotationMirrors contains at least oneAnnotationMirrorfor whichalternate(AnnotationMirror)returnstrue.final booleanReturnstrueif and only if the suppliedAnnotationMirrordesignates whatever it annotates as being an alternate.final booleanfinal booleanReturnstrueif and only if the suppliedIdhas annotations for whichalternate(Collection)returnstrue.normalize(Collection<? extends Bean<?>> beans) Returns a non-null, determinate, immutableListcontaining a subset of distinct elements contained in the suppliedCollection, sorted in a deliberately unspecified fashion.final intrank(Collection<? extends AnnotationMirror> as) Iterates over the suppliedCollectionofAnnotationMirrors and invokes therank(AnnotationMirror)method on each one until a non-zero result is found and returns that result, or0in all other cases.final intReturns anintrepresenting the rank derivable from the suppliedAnnotationMirror, which may be0, or0if the suppliedAnnotationMirrordoes not or cannot supply a rank.final intfinal intfinal Selectable<Annotated<? extends AnnotatedConstruct>, Bean<?>> typesafeFilteringSelectable(Collection<? extends Bean<?>> beanCollection, Matcher<? super Annotated<? extends AnnotatedConstruct>, ? super Id> m) Normalizes the suppliedCollectionofBeans and returns aSelectablesuitable for it and the suppliedMatcher, using theSelectables.filtering(Collection, BiPredicate)method internally.
-
Constructor Details
-
Beans
-
Beans
Creates a newBeans.- Parameters:
alternate- a non-nullAnnotationMirrorthat will designate aBeanas being an alternaterank- a non-nullAnnotationMirrorthat can be examined to determine the rank of aBeanthat has been deemed to be an alternate- Throws:
NullPointerException- if any argument isnull- See Also:
-
Beans
Creates a newBeans.- Parameters:
d- a non-nullDomainalternate- anAnnotationMirrorthat will designate aBeanas being an alternate; may benull; if non-nullmust have aboolean-typedvalueelementrank- anAnnotationMirrorthat can be examined to determine the rank of aBeanthat has been deemed to be an alternate; may benull; if non-nullmust have anint-typedvalueelement
-
-
Method Details
-
normalize
Returns a non-null, determinate, immutableListcontaining a subset of distinct elements contained in the suppliedCollection, sorted in a deliberately unspecified fashion.- Parameters:
beans- aCollectionofBeans; must not benull- Returns:
- a non-
null, determinate, immutableList - Throws:
NullPointerException- ifbeansisnull- See Also:
-
typesafeFilteringSelectable
public final Selectable<Annotated<? extends AnnotatedConstruct>, Bean<?>> typesafeFilteringSelectable(Collection<? extends Bean<?>> beanCollection, Matcher<? super Annotated<? extends AnnotatedConstruct>, ? super Id> m) Normalizes the suppliedCollectionofBeans and returns aSelectablesuitable for it and the suppliedMatcher, using theSelectables.filtering(Collection, BiPredicate)method internally.The returned
Selectabledoes not cache its results or resolve ambiguities.- Parameters:
beanCollection- aCollectionofBeans; must not benullm- aMatcher; must not benull- Returns:
- a non-
null, determinateSelectable - Throws:
NullPointerException- if any argument isnull- See Also:
-
alternate
- Parameters:
b- a non-nullBean- Returns:
trueif and only if the suppliedBeanhas anIdfor whichalternate(Id)returnstrue- Throws:
NullPointerException- ifbisnull- See Also:
-
alternate
Returnstrueif and only if the suppliedIdhas annotations for whichalternate(Collection)returnstrue.- Parameters:
id- a non-nullId- Returns:
trueif and only if the suppliedIdhas annotations for whichalternate(Collection)returnstrue- Throws:
NullPointerException- ifidisnull- See Also:
-
alternate
Returnstrueif and only if the suppliedCollectionofAnnotationMirrors contains at least oneAnnotationMirrorfor whichalternate(AnnotationMirror)returnstrue.- Parameters:
as- a non-nullCollectionofAnnotationMirrors- Returns:
trueif and only if the suppliedCollectionofAnnotationMirrors contains at least oneAnnotationMirrorfor whichalternate(AnnotationMirror)returnstrue- Throws:
NullPointerException- ifasisnull- See Also:
-
alternate
Returnstrueif and only if the suppliedAnnotationMirrordesignates whatever it annotates as being an alternate.- Parameters:
a- a non-nullAnnotationMirror- Returns:
trueif and only if the suppliedAnnotationMirrordesignates whatever it annotates as being an alternate- Throws:
NullPointerException- ifaisnull- See Also:
-
rank
-
rank
- Parameters:
id- a non-nullId- Returns:
- a rank, which may be
0 - Throws:
NullPointerException- ifidisnull- See Also:
-
rank
Iterates over the suppliedCollectionofAnnotationMirrors and invokes therank(AnnotationMirror)method on each one until a non-zero result is found and returns that result, or0in all other cases.- Parameters:
as- a non-nullCollectionofAnnotationMirrors- Returns:
- a rank, which may be
0 - Throws:
NullPointerException- ifasisnull- See Also:
-
rank
Returns anintrepresenting the rank derivable from the suppliedAnnotationMirror, which may be0, or0if the suppliedAnnotationMirrordoes not or cannot supply a rank.- Parameters:
a- a non-nullAnnotationMirror- Returns:
- an
intrepresenting the rank derivable from the suppliedAnnotationMirror, which may be0, or0if the suppliedAnnotationMirrordoes not or cannot supply a rank - Throws:
NullPointerException- ifaisnull- See Also:
-