/** * Returns whether the value of the given member is present. * * @param annotation The annotation class * @param member The annotation member * @return True if the value is true */ default boolean isPresent(@Nonnull String annotation, @Nonnull String member) { ArgumentUtils.requireNonNull("annotation", annotation); ArgumentUtils.requireNonNull("member", member); return findAnnotation(annotation).map(av -> av.contains(member)).orElse(false); }
Optional<Class> beanType = replacesAnn.getValue(Class.class); Optional<Class> factory = replacesAnn.get("factory", Class.class); if (replacesAnn.contains(NAMED_MEMBER)) {
Optional<Class> beanType = replacesAnn.getValue(Class.class); Optional<Class> factory = replacesAnn.get("factory", Class.class); if (replacesAnn.contains(NAMED_MEMBER)) {
private boolean matchesPresenceOfEntities(ConditionContext context, AnnotationValue<Requires> annotationValue) { if (annotationValue.contains("entities")) { Optional<AnnotationClassValue[]> classNames = annotationValue.get("entities", AnnotationClassValue[].class); if (classNames.isPresent()) { BeanContext beanContext = context.getBeanContext(); if (beanContext instanceof ApplicationContext) { ApplicationContext applicationContext = (ApplicationContext) beanContext; final AnnotationClassValue[] classValues = classNames.get(); for (AnnotationClassValue<?> classValue : classValues) { final Optional<? extends Class<?>> entityType = classValue.getType(); if (!entityType.isPresent()) { context.fail("Annotation type [" + classValue.getName() + "] not present on classpath"); return false; } else { Environment environment = applicationContext.getEnvironment(); Class annotationType = entityType.get(); if (!environment.scan(annotationType).findFirst().isPresent()) { context.fail("No entities found in packages [" + String.join(", ", environment.getPackages()) + "] for annotation: " + annotationType); return false; } } } } } } return true; }
private boolean matchesPresenceOfEntities(ConditionContext context, AnnotationValue<Requires> annotationValue) { if (annotationValue.contains("entities")) { Optional<AnnotationClassValue[]> classNames = annotationValue.get("entities", AnnotationClassValue[].class); if (classNames.isPresent()) { BeanContext beanContext = context.getBeanContext(); if (beanContext instanceof ApplicationContext) { ApplicationContext applicationContext = (ApplicationContext) beanContext; final AnnotationClassValue[] classValues = classNames.get(); for (AnnotationClassValue<?> classValue : classValues) { final Optional<? extends Class<?>> entityType = classValue.getType(); if (!entityType.isPresent()) { context.fail("Annotation type [" + classValue.getName() + "] not present on classpath"); return false; } else { Environment environment = applicationContext.getEnvironment(); Class annotationType = entityType.get(); if (!environment.scan(annotationType).findFirst().isPresent()) { context.fail("No entities found in packages [" + String.join(", ", environment.getPackages()) + "] for annotation: " + annotationType); return false; } } } } } } return true; }
private boolean matchesPresenceOfClasses(ConditionContext context, AnnotationValue<Requires> requirements, String attr) { if (requirements.contains(attr)) { Optional<AnnotationClassValue[]> classNames = requirements.get(attr, AnnotationClassValue[].class); if (classNames.isPresent()) { AnnotationClassValue[] classValues = classNames.get(); for (AnnotationClassValue classValue : classValues) { if (!classValue.getType().isPresent()) { context.fail("Class [" + classValue.getName() + "] is not present"); if (ClassLoadingReporter.isReportingEnabled()) { for (AnnotationClassValue cv : classValues) { ClassLoadingReporter.reportMissing(cv.getName()); } reportMissingClass(context); } return false; } } } } return true; }
private boolean matchesPresenceOfClasses(ConditionContext context, AnnotationValue<Requires> requirements, String attr) { if (requirements.contains(attr)) { Optional<AnnotationClassValue[]> classNames = requirements.get(attr, AnnotationClassValue[].class); if (classNames.isPresent()) { AnnotationClassValue[] classValues = classNames.get(); for (AnnotationClassValue classValue : classValues) { if (!classValue.getType().isPresent()) { context.fail("Class [" + classValue.getName() + "] is not present"); if (ClassLoadingReporter.isReportingEnabled()) { for (AnnotationClassValue cv : classValues) { ClassLoadingReporter.reportMissing(cv.getName()); } reportMissingClass(context); } return false; } } } } return true; }