Reformat code following spring-javaformat upgrade
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -101,7 +101,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
||||
static final String AUTO_CONFIGURATION_ANNOTATION = "org.springframework.boot.autoconfigure.AutoConfiguration";
|
||||
|
||||
private static final Set<String> SUPPORTED_OPTIONS = Collections
|
||||
.unmodifiableSet(Collections.singleton(ADDITIONAL_METADATA_LOCATIONS_OPTION));
|
||||
.unmodifiableSet(Collections.singleton(ADDITIONAL_METADATA_LOCATIONS_OPTION));
|
||||
|
||||
private MetadataStore metadataStore;
|
||||
|
||||
@@ -235,8 +235,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
||||
this.metadataEnv.getTypeUtils().getQualifiedName(element.getEnclosingElement()),
|
||||
element.toString());
|
||||
if (this.metadataCollector.hasSimilarGroup(group)) {
|
||||
this.processingEnv.getMessager().printMessage(Kind.ERROR,
|
||||
"Duplicate @ConfigurationProperties definition for prefix '" + prefix + "'", element);
|
||||
this.processingEnv.getMessager()
|
||||
.printMessage(Kind.ERROR,
|
||||
"Duplicate @ConfigurationProperties definition for prefix '" + prefix + "'", element);
|
||||
}
|
||||
else {
|
||||
this.metadataCollector.add(group);
|
||||
@@ -254,7 +255,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
||||
this.metadataCollector.add(descriptor.resolveItemMetadata(prefix, this.metadataEnv));
|
||||
if (descriptor.isNested(this.metadataEnv)) {
|
||||
TypeElement nestedTypeElement = (TypeElement) this.metadataEnv.getTypeUtils()
|
||||
.asElement(descriptor.getType());
|
||||
.asElement(descriptor.getType());
|
||||
String nestedPrefix = ConfigurationMetadata.nestedPrefix(prefix, descriptor.getName());
|
||||
processTypeElement(nestedPrefix, nestedTypeElement, source, seen);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -69,8 +69,9 @@ class ConstructorParameterPropertyDescriptor extends PropertyDescriptor<Variable
|
||||
if (defaultValue.size() == 1) {
|
||||
return coerceValue(specificType, defaultValue.get(0));
|
||||
}
|
||||
return defaultValue.stream().map((value) -> coerceValue(specificType, value))
|
||||
.collect(Collectors.toList());
|
||||
return defaultValue.stream()
|
||||
.map((value) -> coerceValue(specificType, value))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
environment.getMessager().printMessage(Kind.ERROR, ex.getMessage(), element, annotation);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -242,7 +242,7 @@ class MetadataGenerationEnvironment {
|
||||
Map<String, Object> getAnnotationElementValues(AnnotationMirror annotation) {
|
||||
Map<String, Object> values = new LinkedHashMap<>();
|
||||
annotation.getElementValues()
|
||||
.forEach((name, value) -> values.put(name.getSimpleName().toString(), getAnnotationValue(value)));
|
||||
.forEach((name, value) -> values.put(name.getSimpleName().toString(), getAnnotationValue(value)));
|
||||
return values;
|
||||
}
|
||||
|
||||
@@ -273,8 +273,10 @@ class MetadataGenerationEnvironment {
|
||||
}
|
||||
|
||||
Set<TypeElement> getEndpointAnnotationElements() {
|
||||
return this.endpointAnnotations.stream().map(this.elements::getTypeElement).filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
return this.endpointAnnotations.stream()
|
||||
.map(this.elements::getTypeElement)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
AnnotationMirror getReadOperationAnnotation(Element element) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -102,8 +102,8 @@ public class MetadataStore {
|
||||
|
||||
private InputStream getAdditionalMetadataStream() throws IOException {
|
||||
// Most build systems will have copied the file to the class output location
|
||||
FileObject fileObject = this.environment.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "",
|
||||
ADDITIONAL_METADATA_PATH);
|
||||
FileObject fileObject = this.environment.getFiler()
|
||||
.getResource(StandardLocation.CLASS_OUTPUT, "", ADDITIONAL_METADATA_PATH);
|
||||
File file = locateAdditionalMetadataFile(new File(fileObject.toUri()));
|
||||
return (file.exists() ? new FileInputStream(file) : fileObject.toUri().toURL().openStream());
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class MetadataStore {
|
||||
return standardLocation;
|
||||
}
|
||||
String locations = this.environment.getOptions()
|
||||
.get(ConfigurationMetadataAnnotationProcessor.ADDITIONAL_METADATA_LOCATIONS_OPTION);
|
||||
.get(ConfigurationMetadataAnnotationProcessor.ADDITIONAL_METADATA_LOCATIONS_OPTION);
|
||||
if (locations != null) {
|
||||
for (String location : locations.split(",")) {
|
||||
File candidate = new File(location, ADDITIONAL_METADATA_PATH);
|
||||
|
||||
@@ -191,7 +191,8 @@ class PropertyDescriptorResolver {
|
||||
boolean constructorBoundType = isConstructorBoundType(type, env);
|
||||
List<ExecutableElement> constructors = ElementFilter.constructorsIn(type.getEnclosedElements());
|
||||
List<ExecutableElement> boundConstructors = constructors.stream()
|
||||
.filter(env::hasConstructorBindingAnnotation).collect(Collectors.toList());
|
||||
.filter(env::hasConstructorBindingAnnotation)
|
||||
.collect(Collectors.toList());
|
||||
return new ConfigurationPropertiesTypeElement(type, constructorBoundType, constructors, boundConstructors);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -234,7 +234,8 @@ class TypeUtils {
|
||||
if (type.getKind() == TypeKind.DECLARED) {
|
||||
DeclaredType declaredType = (DeclaredType) type;
|
||||
DeclaredType freshType = (DeclaredType) this.env.getElementUtils()
|
||||
.getTypeElement(this.types.asElement(type).toString()).asType();
|
||||
.getTypeElement(this.types.asElement(type).toString())
|
||||
.asType();
|
||||
List<? extends TypeMirror> arguments = declaredType.getTypeArguments();
|
||||
for (int i = 0; i < arguments.size(); i++) {
|
||||
TypeMirror specificType = arguments.get(i);
|
||||
@@ -267,9 +268,12 @@ class TypeUtils {
|
||||
}
|
||||
StringBuilder name = new StringBuilder();
|
||||
name.append(qualifiedName);
|
||||
name.append("<").append(
|
||||
type.getTypeArguments().stream().map((t) -> visit(t, descriptor)).collect(Collectors.joining(",")))
|
||||
.append(">");
|
||||
name.append("<")
|
||||
.append(type.getTypeArguments()
|
||||
.stream()
|
||||
.map((t) -> visit(t, descriptor))
|
||||
.collect(Collectors.joining(",")))
|
||||
.append(">");
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
@@ -303,8 +307,9 @@ class TypeUtils {
|
||||
private boolean hasCycle(TypeVariable variable) {
|
||||
TypeMirror upperBound = variable.getUpperBound();
|
||||
if (upperBound instanceof DeclaredType) {
|
||||
return ((DeclaredType) upperBound).getTypeArguments().stream()
|
||||
.anyMatch((candidate) -> candidate.equals(variable));
|
||||
return ((DeclaredType) upperBound).getTypeArguments()
|
||||
.stream()
|
||||
.anyMatch((candidate) -> candidate.equals(variable));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -368,15 +373,20 @@ class TypeUtils {
|
||||
}
|
||||
|
||||
TypeMirror resolveGeneric(String parameterName) {
|
||||
return this.generics.entrySet().stream().filter((e) -> getParameterName(e.getKey()).equals(parameterName))
|
||||
.findFirst().map(Entry::getValue).orElse(null);
|
||||
return this.generics.entrySet()
|
||||
.stream()
|
||||
.filter((e) -> getParameterName(e.getKey()).equals(parameterName))
|
||||
.findFirst()
|
||||
.map(Entry::getValue)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private void registerIfNecessary(TypeMirror variable, TypeMirror resolution) {
|
||||
if (variable instanceof TypeVariable) {
|
||||
TypeVariable typeVariable = (TypeVariable) variable;
|
||||
if (this.generics.keySet().stream()
|
||||
.noneMatch((candidate) -> getParameterName(candidate).equals(getParameterName(typeVariable)))) {
|
||||
if (this.generics.keySet()
|
||||
.stream()
|
||||
.noneMatch((candidate) -> getParameterName(candidate).equals(getParameterName(typeVariable)))) {
|
||||
this.generics.put(typeVariable, resolution);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -39,8 +39,11 @@ class JsonConverter {
|
||||
|
||||
JSONArray toJsonArray(ConfigurationMetadata metadata, ItemType itemType) throws Exception {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
List<ItemMetadata> items = metadata.getItems().stream().filter((item) -> item.isOfItemType(itemType))
|
||||
.sorted(ITEM_COMPARATOR).collect(Collectors.toList());
|
||||
List<ItemMetadata> items = metadata.getItems()
|
||||
.stream()
|
||||
.filter((item) -> item.isOfItemType(itemType))
|
||||
.sorted(ITEM_COMPARATOR)
|
||||
.collect(Collectors.toList());
|
||||
for (ItemMetadata item : items) {
|
||||
if (item.isOfItemType(itemType)) {
|
||||
jsonArray.put(toJsonObject(item));
|
||||
@@ -161,11 +164,11 @@ class JsonConverter {
|
||||
private static class ItemMetadataComparator implements Comparator<ItemMetadata> {
|
||||
|
||||
private static final Comparator<ItemMetadata> GROUP = Comparator.comparing(ItemMetadata::getName)
|
||||
.thenComparing(ItemMetadata::getSourceType, Comparator.nullsFirst(Comparator.naturalOrder()));
|
||||
.thenComparing(ItemMetadata::getSourceType, Comparator.nullsFirst(Comparator.naturalOrder()));
|
||||
|
||||
private static final Comparator<ItemMetadata> ITEM = Comparator.comparing(ItemMetadataComparator::isDeprecated)
|
||||
.thenComparing(ItemMetadata::getName)
|
||||
.thenComparing(ItemMetadata::getSourceType, Comparator.nullsFirst(Comparator.naturalOrder()));
|
||||
.thenComparing(ItemMetadata::getName)
|
||||
.thenComparing(ItemMetadata::getSourceType, Comparator.nullsFirst(Comparator.naturalOrder()));
|
||||
|
||||
@Override
|
||||
public int compare(ItemMetadata o1, ItemMetadata o2) {
|
||||
|
||||
Reference in New Issue
Block a user