BindingConditions { public static <T> BindingCondition<T> and(final BindingCondition<T>... conditions) { return new BindingCondition<T>() { @Override public boolean fulfilled(ClassInjector injector, Class<T> type, Map<String, Class<? extends T>[]> inheritanceTree, Annotation qualifier, ClassLoader classLoader) { if (conditions != null && conditions.length > 1) { for (BindingCondition<T> condition : conditions) { if (!condition.fulfilled(injector, type, inheritanceTree, qualifier, classLoader)) { return false; } } } else if (conditions.length > 0) { return conditions[0].fulfilled(injector, type, inheritanceTree, qualifier, classLoader); } return true; } }; }  @SuppressWarnings("unchecked") static BindingCondition<T> annotationIsPresent(Class<? extends T> type, Class<? extends Annotation> annotation); static BindingCondition<T> qualifierIs(Class<? extends T> type, final Class<? extends Annotation> expectedQualifier); static BindingCondition<T> isNamed(Class<? extends T> type, final CharSequence value); static BindingCondition<T> isNamedIgnoringCase(Class<? extends T> type, final CharSequence value); static BindingCondition<T> allAnnotationsArePresent(Class<? extends T> type, final Class<? extends Annotation>... annotations); static BindingCondition<T> anyAnnotationIsPresent(Class<? extends T> type, final Class<? extends Annotation>... annotations); static BindingCondition<T> and(final BindingCondition<T>... conditions); static BindingCondition<T> or(final BindingCondition<T>... conditions); static BindingCondition<T> xor(final BindingCondition<T> condition1, final BindingCondition<T> condition2);  }
@SuppressWarnings("unchecked") @Test public void and() { assertTrue(BindingConditions.and(confirming).fulfilled(null, Object.class, null, null, classLoader)); assertFalse(BindingConditions.and(nonConfirming).fulfilled(null, Object.class, null, null, classLoader)); assertTrue(BindingConditions.and(confirming, confirming).fulfilled(null, Object.class, null, null, classLoader)); assertFalse(BindingConditions.and(nonConfirming, nonConfirming).fulfilled(null, Object.class, null, null, classLoader)); assertFalse(BindingConditions.and(confirming, nonConfirming).fulfilled(null, Object.class, null, null, classLoader)); assertFalse(BindingConditions.and(nonConfirming, confirming).fulfilled(null, Object.class, null, null, classLoader)); }