@Test public void springStereotypeScopes() { final Map<DotName, Set<DotName>> scopes = processor.getStereotypeScopes(index); final Map<DotName, Set<DotName>> expected = new HashMap<>(); expected.put(SpringDIProcessor.SPRING_COMPONENT, Collections.emptySet()); expected.put(SpringDIProcessor.SPRING_SERVICE, Collections.emptySet()); expected.put(SpringDIProcessor.SPRING_REPOSITORY, Collections.emptySet()); expected.put(DotName.createSimple(PrototypeService.class.getName()), Collections.singleton(DotName.createSimple(Dependent.class.getName()))); expected.put(DotName.createSimple(RequestService.class.getName()), Collections.singleton(DotName.createSimple(RequestScoped.class.getName()))); expected.put(DotName.createSimple(UndeclaredService.class.getName()), Collections.emptySet()); expected.put(DotName.createSimple(ConflictService.class.getName()), setOf( DotName.createSimple(Dependent.class.getName()), DotName.createSimple(RequestScoped.class.getName()))); assertEquals(expected, scopes); }
Map<DotName, Set<DotName>> getStereotypeScopes(final IndexView index) { final Map<DotName, Set<DotName>> scopes = new HashMap<>(); scopes.put(SPRING_COMPONENT, Collections.emptySet()); scopes.put(SPRING_REPOSITORY, Collections.emptySet()); scopes.put(SPRING_SERVICE, Collections.emptySet()); final List<ClassInfo> allAnnotations = getOrderedAnnotations(index); final Set<DotName> stereotypeClasses = new HashSet<>(SPRING_STEREOTYPE_ANNOTATIONS); for (final ClassInfo clazz : allAnnotations) { final Set<DotName> clazzAnnotations = clazz.annotations().keySet(); final Set<DotName> clazzStereotypes = new HashSet<>(); final Set<DotName> clazzScopes = new HashSet<>(); for (final DotName stereotypeName : stereotypeClasses) { if (clazzAnnotations.contains(stereotypeName)) { clazzStereotypes.add(stereotypeName); } } if (clazzStereotypes.isEmpty()) { continue; } final DotName name = clazz.name(); stereotypeClasses.add(name); for (final DotName stereotype : clazzStereotypes) { final Set<DotName> vals = scopes.get(stereotype); if (vals != null) { clazzScopes.addAll(vals); } } final DotName scope = getScope(clazz); if (scope != null) { clazzScopes.add(scope); } scopes.put(name, clazzScopes); } return scopes; }
SpringDIProcessor { Map<DotName, Set<DotName>> getStereotypeScopes(final IndexView index) { final Map<DotName, Set<DotName>> scopes = new HashMap<>(); scopes.put(SPRING_COMPONENT, Collections.emptySet()); scopes.put(SPRING_REPOSITORY, Collections.emptySet()); scopes.put(SPRING_SERVICE, Collections.emptySet()); final List<ClassInfo> allAnnotations = getOrderedAnnotations(index); final Set<DotName> stereotypeClasses = new HashSet<>(SPRING_STEREOTYPE_ANNOTATIONS); for (final ClassInfo clazz : allAnnotations) { final Set<DotName> clazzAnnotations = clazz.annotations().keySet(); final Set<DotName> clazzStereotypes = new HashSet<>(); final Set<DotName> clazzScopes = new HashSet<>(); for (final DotName stereotypeName : stereotypeClasses) { if (clazzAnnotations.contains(stereotypeName)) { clazzStereotypes.add(stereotypeName); } } if (clazzStereotypes.isEmpty()) { continue; } final DotName name = clazz.name(); stereotypeClasses.add(name); for (final DotName stereotype : clazzStereotypes) { final Set<DotName> vals = scopes.get(stereotype); if (vals != null) { clazzScopes.addAll(vals); } } final DotName scope = getScope(clazz); if (scope != null) { clazzScopes.add(scope); } scopes.put(name, clazzScopes); } return scopes; } }
SpringDIProcessor { Map<DotName, Set<DotName>> getStereotypeScopes(final IndexView index) { final Map<DotName, Set<DotName>> scopes = new HashMap<>(); scopes.put(SPRING_COMPONENT, Collections.emptySet()); scopes.put(SPRING_REPOSITORY, Collections.emptySet()); scopes.put(SPRING_SERVICE, Collections.emptySet()); final List<ClassInfo> allAnnotations = getOrderedAnnotations(index); final Set<DotName> stereotypeClasses = new HashSet<>(SPRING_STEREOTYPE_ANNOTATIONS); for (final ClassInfo clazz : allAnnotations) { final Set<DotName> clazzAnnotations = clazz.annotations().keySet(); final Set<DotName> clazzStereotypes = new HashSet<>(); final Set<DotName> clazzScopes = new HashSet<>(); for (final DotName stereotypeName : stereotypeClasses) { if (clazzAnnotations.contains(stereotypeName)) { clazzStereotypes.add(stereotypeName); } } if (clazzStereotypes.isEmpty()) { continue; } final DotName name = clazz.name(); stereotypeClasses.add(name); for (final DotName stereotype : clazzStereotypes) { final Set<DotName> vals = scopes.get(stereotype); if (vals != null) { clazzScopes.addAll(vals); } } final DotName scope = getScope(clazz); if (scope != null) { clazzScopes.add(scope); } scopes.put(name, clazzScopes); } return scopes; }  }
SpringDIProcessor { Map<DotName, Set<DotName>> getStereotypeScopes(final IndexView index) { final Map<DotName, Set<DotName>> scopes = new HashMap<>(); scopes.put(SPRING_COMPONENT, Collections.emptySet()); scopes.put(SPRING_REPOSITORY, Collections.emptySet()); scopes.put(SPRING_SERVICE, Collections.emptySet()); final List<ClassInfo> allAnnotations = getOrderedAnnotations(index); final Set<DotName> stereotypeClasses = new HashSet<>(SPRING_STEREOTYPE_ANNOTATIONS); for (final ClassInfo clazz : allAnnotations) { final Set<DotName> clazzAnnotations = clazz.annotations().keySet(); final Set<DotName> clazzStereotypes = new HashSet<>(); final Set<DotName> clazzScopes = new HashSet<>(); for (final DotName stereotypeName : stereotypeClasses) { if (clazzAnnotations.contains(stereotypeName)) { clazzStereotypes.add(stereotypeName); } } if (clazzStereotypes.isEmpty()) { continue; } final DotName name = clazz.name(); stereotypeClasses.add(name); for (final DotName stereotype : clazzStereotypes) { final Set<DotName> vals = scopes.get(stereotype); if (vals != null) { clazzScopes.addAll(vals); } } final DotName scope = getScope(clazz); if (scope != null) { clazzScopes.add(scope); } scopes.put(name, clazzScopes); } return scopes; }   }
SpringDIProcessor { Map<DotName, Set<DotName>> getStereotypeScopes(final IndexView index) { final Map<DotName, Set<DotName>> scopes = new HashMap<>(); scopes.put(SPRING_COMPONENT, Collections.emptySet()); scopes.put(SPRING_REPOSITORY, Collections.emptySet()); scopes.put(SPRING_SERVICE, Collections.emptySet()); final List<ClassInfo> allAnnotations = getOrderedAnnotations(index); final Set<DotName> stereotypeClasses = new HashSet<>(SPRING_STEREOTYPE_ANNOTATIONS); for (final ClassInfo clazz : allAnnotations) { final Set<DotName> clazzAnnotations = clazz.annotations().keySet(); final Set<DotName> clazzStereotypes = new HashSet<>(); final Set<DotName> clazzScopes = new HashSet<>(); for (final DotName stereotypeName : stereotypeClasses) { if (clazzAnnotations.contains(stereotypeName)) { clazzStereotypes.add(stereotypeName); } } if (clazzStereotypes.isEmpty()) { continue; } final DotName name = clazz.name(); stereotypeClasses.add(name); for (final DotName stereotype : clazzStereotypes) { final Set<DotName> vals = scopes.get(stereotype); if (vals != null) { clazzScopes.addAll(vals); } } final DotName scope = getScope(clazz); if (scope != null) { clazzScopes.add(scope); } scopes.put(name, clazzScopes); } return scopes; }    }