Browse Source

CandidateComponentsIndexer introspects any kind of class (including records)

Closes gh-26909
pull/26940/head
Juergen Hoeller 4 years ago
parent
commit
4164fc63b1
  1. 9
      spring-context-indexer/src/main/java/org/springframework/context/index/processor/CandidateComponentsIndexer.java
  2. 4
      spring-context-indexer/src/main/java/org/springframework/context/index/processor/IndexedStereotypesProvider.java

9
spring-context-indexer/src/main/java/org/springframework/context/index/processor/CandidateComponentsIndexer.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.context.index.processor; @@ -19,7 +19,6 @@ package org.springframework.context.index.processor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@ -46,9 +45,6 @@ import javax.lang.model.element.TypeElement; @@ -46,9 +45,6 @@ import javax.lang.model.element.TypeElement;
*/
public class CandidateComponentsIndexer implements Processor {
private static final Set<ElementKind> TYPE_KINDS =
Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS, ElementKind.INTERFACE));
private MetadataStore metadataStore;
private MetadataCollector metadataCollector;
@ -136,7 +132,8 @@ public class CandidateComponentsIndexer implements Processor { @@ -136,7 +132,8 @@ public class CandidateComponentsIndexer implements Processor {
private static List<TypeElement> staticTypesIn(Iterable<? extends Element> elements) {
List<TypeElement> list = new ArrayList<>();
for (Element element : elements) {
if (TYPE_KINDS.contains(element.getKind()) && element.getModifiers().contains(Modifier.STATIC)) {
if ((element.getKind().isClass() || element.getKind() == ElementKind.INTERFACE) &&
element.getModifiers().contains(Modifier.STATIC) && element instanceof TypeElement) {
list.add((TypeElement) element);
}
}

4
spring-context-indexer/src/main/java/org/springframework/context/index/processor/IndexedStereotypesProvider.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -48,7 +48,7 @@ class IndexedStereotypesProvider implements StereotypesProvider { @@ -48,7 +48,7 @@ class IndexedStereotypesProvider implements StereotypesProvider {
public Set<String> getStereotypes(Element element) {
Set<String> stereotypes = new LinkedHashSet<>();
ElementKind kind = element.getKind();
if (kind != ElementKind.CLASS && kind != ElementKind.INTERFACE) {
if (!kind.isClass() && kind != ElementKind.INTERFACE) {
return stereotypes;
}
Set<Element> seen = new HashSet<>();

Loading…
Cancel
Save