private static boolean isSpringInjectionAnnotated(SymbolMetadata metadata) { return metadata.isAnnotatedWith("org.springframework.beans.factory.annotation.Autowired") || metadata.isAnnotatedWith("javax.inject.Inject") || metadata.isAnnotatedWith("javax.annotation.Resource"); } }
private static boolean isSilentlyIgnored(SymbolMetadata symbolMetadata, String annotation) { List<SymbolMetadata.AnnotationValue> annotationValues = symbolMetadata.valuesForAnnotation(annotation); return annotationValues != null && annotationValues.isEmpty(); }
private static boolean hasAnnotation(Symbol s) { return !s.metadata().annotations().isEmpty(); }
private boolean isJUnitTestableMetaAnnotated(Type type) { if (seenAnnotations.contains(type.fullyQualifiedName())) { return false; } seenAnnotations.add(type.fullyQualifiedName()); SymbolMetadata metadata = type.symbol().metadata(); if (metadata.isAnnotatedWith("org.junit.platform.commons.annotation.Testable")) { testAnnotations.add(type.fullyQualifiedName()); return true; } for (SymbolMetadata.AnnotationInstance annotation : metadata.annotations()) { if (isJUnitTestableMetaAnnotated(annotation.symbol().type())) { testAnnotations.add(type.fullyQualifiedName()); return true; } } return false; }
private boolean isJUnitTestableMetaAnnotated(Type type) { if (seenAnnotations.contains(type.fullyQualifiedName())) { return false; } seenAnnotations.add(type.fullyQualifiedName()); SymbolMetadata metadata = type.symbol().metadata(); if (metadata.isAnnotatedWith("org.junit.platform.commons.annotation.Testable")) { testAnnotations.add(type.fullyQualifiedName()); return true; } for (SymbolMetadata.AnnotationInstance annotation : metadata.annotations()) { if (isJUnitTestableMetaAnnotated(annotation.symbol().type())) { testAnnotations.add(type.fullyQualifiedName()); return true; } } return false; }
private static boolean isSpringInjectionAnnotated(SymbolMetadata metadata) { return metadata.isAnnotatedWith("org.springframework.beans.factory.annotation.Autowired") || metadata.isAnnotatedWith("javax.inject.Inject") || metadata.isAnnotatedWith("javax.annotation.Resource") || metadata.isAnnotatedWith("org.springframework.beans.factory.annotation.Value"); }
private static boolean isSilentlyIgnored(SymbolMetadata symbolMetadata, String annotation) { List<SymbolMetadata.AnnotationValue> annotationValues = symbolMetadata.valuesForAnnotation(annotation); return annotationValues != null && annotationValues.isEmpty(); }
private static boolean hasAnnotation(Symbol s) { return !s.metadata().annotations().isEmpty(); }
private static boolean isSpringComponent(SymbolMetadata clazzMeta) { return clazzMeta.isAnnotatedWith("org.springframework.stereotype.Controller") || clazzMeta.isAnnotatedWith("org.springframework.stereotype.Service") || clazzMeta.isAnnotatedWith("org.springframework.stereotype.Repository"); }
@CheckForNull private static String getPropagation(Symbol symbol, @Nullable String inheritedPropagation) { String defaultValue = inheritedPropagation != null ? inheritedPropagation : REQUIRED; List<AnnotationValue> values = symbol.metadata().valuesForAnnotation(SPRING_TRANSACTIONAL_ANNOTATION); if (values != null) { return getAnnotationAttributeAsString(values, "propagation", defaultValue); } else { values = symbol.metadata().valuesForAnnotation(JAVAX_TRANSACTIONAL_ANNOTATION); if (values != null) { return getAnnotationAttributeAsString(values, "value", defaultValue); } else { return inheritedPropagation; } } }
private static boolean isServletOrEjb(Symbol symbol) { if (SERVLET_AND_EJB_CLASSES.stream().anyMatch(symbol.type()::isSubtypeOf)) { return true; } return symbol.metadata().annotations().stream().anyMatch(annotation -> annotation.symbol().type().fullyQualifiedName().startsWith("javax.ejb.")); }
private static boolean isSpringComponent(SymbolMetadata clazzMeta) { return clazzMeta.isAnnotatedWith("org.springframework.stereotype.Controller") || clazzMeta.isAnnotatedWith("org.springframework.stereotype.Service") || clazzMeta.isAnnotatedWith("org.springframework.stereotype.Repository"); } }
@CheckForNull private static String getPropagation(Symbol symbol, @Nullable String inheritedPropagation) { String defaultValue = inheritedPropagation != null ? inheritedPropagation : REQUIRED; List<AnnotationValue> values = symbol.metadata().valuesForAnnotation(SPRING_TRANSACTIONAL_ANNOTATION); if (values != null) { return getAnnotationAttributeAsString(values, "propagation", defaultValue); } else { values = symbol.metadata().valuesForAnnotation(JAVAX_TRANSACTIONAL_ANNOTATION); if (values != null) { return getAnnotationAttributeAsString(values, "value", defaultValue); } else { return inheritedPropagation; } } }
private static boolean isServletOrEjb(Symbol symbol) { if (SERVLET_AND_EJB_CLASSES.stream().anyMatch(symbol.type()::isSubtypeOf)) { return true; } return symbol.metadata().annotations().stream().anyMatch(annotation -> annotation.symbol().type().fullyQualifiedName().startsWith("javax.ejb.")); }
private static boolean isSpringComponent(SymbolMetadata clazzMeta) { return clazzMeta.isAnnotatedWith("org.springframework.stereotype.Controller") || clazzMeta.isAnnotatedWith("org.springframework.stereotype.Service") || clazzMeta.isAnnotatedWith("org.springframework.stereotype.Repository"); }
private static boolean checkRunWith(Symbol.TypeSymbol symbol, String... runnerClasses) { List<SymbolMetadata.AnnotationValue> annotationValues = symbol.metadata().valuesForAnnotation("org.junit.runner.RunWith"); if (annotationValues != null && annotationValues.size() == 1) { Object value = annotationValues.get(0).value(); if (value instanceof MemberSelectExpressionTree) { String runnerParam = ExpressionsHelper.concatenate((ExpressionTree) value); for (String runnerClass : runnerClasses) { if (runnerParam.endsWith(runnerClass)) { return true; } } } } return false; }
private static boolean isNotEJBAnnotated(Symbol symbol) { return symbol.metadata().annotations().stream().noneMatch(a -> a.symbol().owner().name().equals("javax.ejb")); }
private static boolean isSpringInjectionAnnotated(SymbolMetadata metadata) { return metadata.isAnnotatedWith("org.springframework.beans.factory.annotation.Autowired") || metadata.isAnnotatedWith("javax.inject.Inject") || metadata.isAnnotatedWith("javax.annotation.Resource") || metadata.isAnnotatedWith("org.springframework.beans.factory.annotation.Value"); }
private static boolean checkRunWith(Symbol.TypeSymbol symbol, String... runnerClasses) { List<SymbolMetadata.AnnotationValue> annotationValues = symbol.metadata().valuesForAnnotation("org.junit.runner.RunWith"); if (annotationValues != null && annotationValues.size() == 1) { Object value = annotationValues.get(0).value(); if (value instanceof MemberSelectExpressionTree) { String runnerParam = ExpressionsHelper.concatenate((ExpressionTree) value); for (String runnerClass : runnerClasses) { if (runnerParam.endsWith(runnerClass)) { return true; } } } } return false; }
private static boolean isNotEJBAnnotated(Symbol symbol) { return symbol.metadata().annotations().stream().noneMatch(a -> a.symbol().owner().name().equals("javax.ejb")); }