CandidateComponentsIndexer introspects any kind of class (including records)
Closes gh-26909
This commit is contained in:
parent
0865abef83
commit
4164fc63b1
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -19,7 +19,6 @@ package org.springframework.context.index.processor;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -46,9 +45,6 @@ import javax.lang.model.element.TypeElement;
|
||||||
*/
|
*/
|
||||||
public class CandidateComponentsIndexer implements Processor {
|
public class CandidateComponentsIndexer implements Processor {
|
||||||
|
|
||||||
private static final Set<ElementKind> TYPE_KINDS =
|
|
||||||
Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS, ElementKind.INTERFACE));
|
|
||||||
|
|
||||||
private MetadataStore metadataStore;
|
private MetadataStore metadataStore;
|
||||||
|
|
||||||
private MetadataCollector metadataCollector;
|
private MetadataCollector metadataCollector;
|
||||||
|
@ -136,7 +132,8 @@ public class CandidateComponentsIndexer implements Processor {
|
||||||
private static List<TypeElement> staticTypesIn(Iterable<? extends Element> elements) {
|
private static List<TypeElement> staticTypesIn(Iterable<? extends Element> elements) {
|
||||||
List<TypeElement> list = new ArrayList<>();
|
List<TypeElement> list = new ArrayList<>();
|
||||||
for (Element element : elements) {
|
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);
|
list.add((TypeElement) element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -48,7 +48,7 @@ class IndexedStereotypesProvider implements StereotypesProvider {
|
||||||
public Set<String> getStereotypes(Element element) {
|
public Set<String> getStereotypes(Element element) {
|
||||||
Set<String> stereotypes = new LinkedHashSet<>();
|
Set<String> stereotypes = new LinkedHashSet<>();
|
||||||
ElementKind kind = element.getKind();
|
ElementKind kind = element.getKind();
|
||||||
if (kind != ElementKind.CLASS && kind != ElementKind.INTERFACE) {
|
if (!kind.isClass() && kind != ElementKind.INTERFACE) {
|
||||||
return stereotypes;
|
return stereotypes;
|
||||||
}
|
}
|
||||||
Set<Element> seen = new HashSet<>();
|
Set<Element> seen = new HashSet<>();
|
||||||
|
|
Loading…
Reference in New Issue