Use Deque instead of Stack

pull/36455/head
Moritz Halbritter 1 year ago
parent a1f30a2316
commit 0588f9bf37

@ -20,14 +20,15 @@ import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.Duration;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
@ -214,10 +215,10 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
if (annotation != null) {
String prefix = getPrefix(annotation);
if (element instanceof TypeElement typeElement) {
processAnnotatedTypeElement(prefix, typeElement, new Stack<>());
processAnnotatedTypeElement(prefix, typeElement, new ArrayDeque<>());
}
else if (element instanceof ExecutableElement executableElement) {
processExecutableElement(prefix, executableElement, new Stack<>());
processExecutableElement(prefix, executableElement, new ArrayDeque<>());
}
}
}
@ -226,13 +227,13 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
}
}
private void processAnnotatedTypeElement(String prefix, TypeElement element, Stack<TypeElement> seen) {
private void processAnnotatedTypeElement(String prefix, TypeElement element, Deque<TypeElement> seen) {
String type = this.metadataEnv.getTypeUtils().getQualifiedName(element);
this.metadataCollector.add(ItemMetadata.newGroup(prefix, type, type, null));
processTypeElement(prefix, element, null, seen);
}
private void processExecutableElement(String prefix, ExecutableElement element, Stack<TypeElement> seen) {
private void processExecutableElement(String prefix, ExecutableElement element, Deque<TypeElement> seen) {
if ((!element.getModifiers().contains(Modifier.PRIVATE))
&& (TypeKind.VOID != element.getReturnType().getKind())) {
Element returns = this.processingEnv.getTypeUtils().asElement(element.getReturnType());
@ -255,7 +256,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
}
private void processTypeElement(String prefix, TypeElement element, ExecutableElement source,
Stack<TypeElement> seen) {
Deque<TypeElement> seen) {
if (!seen.contains(element)) {
seen.push(element);
new PropertyDescriptorResolver(this.metadataEnv).resolve(element, source).forEach((descriptor) -> {

Loading…
Cancel
Save