Skip to content

Commit 6bc37c0

Browse files
committed
Drop annotation processor spring-core dependency
Remove the spring-core dependency from the annotation processor. (cherry-picked from 4cb7d86) Fixes spring-projectsgh-7882
1 parent 7320119 commit 6bc37c0

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

spring-boot-tools/spring-boot-configuration-processor/pom.xml

-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
<artifactId>lombok</artifactId>
3030
<scope>test</scope>
3131
</dependency>
32-
<dependency>
33-
<groupId>org.springframework</groupId>
34-
<artifactId>spring-core</artifactId>
35-
</dependency>
3632
</dependencies>
3733
<build>
3834
<plugins>

spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java

+30-19
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,12 @@
2020
import java.util.Arrays;
2121
import java.util.Collections;
2222
import java.util.HashSet;
23+
import java.util.LinkedHashMap;
2324
import java.util.List;
2425
import java.util.ListIterator;
26+
import java.util.Map;
2527
import java.util.Set;
2628

27-
import org.springframework.util.CollectionUtils;
28-
import org.springframework.util.LinkedMultiValueMap;
29-
import org.springframework.util.MultiValueMap;
30-
import org.springframework.util.ObjectUtils;
31-
3229
/**
3330
* Configuration meta-data.
3431
*
@@ -46,34 +43,34 @@ public class ConfigurationMetadata {
4643
SEPARATORS = Collections.unmodifiableSet(new HashSet<Character>(chars));
4744
}
4845

49-
private final MultiValueMap<String, ItemMetadata> items;
46+
private final Map<String, List<ItemMetadata>> items;
5047

51-
private final MultiValueMap<String, ItemHint> hints;
48+
private final Map<String, List<ItemHint>> hints;
5249

5350
public ConfigurationMetadata() {
54-
this.items = new LinkedMultiValueMap<String, ItemMetadata>();
55-
this.hints = new LinkedMultiValueMap<String, ItemHint>();
51+
this.items = new LinkedHashMap<String, List<ItemMetadata>>();
52+
this.hints = new LinkedHashMap<String, List<ItemHint>>();
5653
}
5754

5855
public ConfigurationMetadata(ConfigurationMetadata metadata) {
59-
this.items = new LinkedMultiValueMap<String, ItemMetadata>(metadata.items);
60-
this.hints = new LinkedMultiValueMap<String, ItemHint>(metadata.hints);
56+
this.items = new LinkedHashMap<String, List<ItemMetadata>>(metadata.items);
57+
this.hints = new LinkedHashMap<String, List<ItemHint>>(metadata.hints);
6158
}
6259

6360
/**
6461
* Add item meta-data.
6562
* @param itemMetadata the meta-data to add
6663
*/
6764
public void add(ItemMetadata itemMetadata) {
68-
this.items.add(itemMetadata.getName(), itemMetadata);
65+
add(this.items, itemMetadata.getName(), itemMetadata);
6966
}
7067

7168
/**
7269
* Add item hint.
7370
* @param itemHint the item hint to add
7471
*/
7572
public void add(ItemHint itemHint) {
76-
this.hints.add(itemHint.getName(), itemHint);
73+
add(this.hints, itemHint.getName(), itemHint);
7774
}
7875

7976
/**
@@ -131,13 +128,22 @@ protected void mergeItemMetadata(ItemMetadata metadata) {
131128
}
132129
}
133130
else {
134-
this.items.add(metadata.getName(), metadata);
131+
add(this.items, metadata.getName(), metadata);
132+
}
133+
}
134+
135+
private <K, V> void add(Map<K, List<V>> map, K key, V value) {
136+
List<V> values = map.get(key);
137+
if (values == null) {
138+
values = new ArrayList<V>();
139+
map.put(key, values);
135140
}
141+
values.add(value);
136142
}
137143

138144
private ItemMetadata findMatchingItemMetadata(ItemMetadata metadata) {
139145
List<ItemMetadata> candidates = this.items.get(metadata.getName());
140-
if (CollectionUtils.isEmpty(candidates)) {
146+
if (candidates == null || candidates.isEmpty()) {
141147
return null;
142148
}
143149
ListIterator<ItemMetadata> it = candidates.listIterator();
@@ -150,14 +156,20 @@ private ItemMetadata findMatchingItemMetadata(ItemMetadata metadata) {
150156
return candidates.get(0);
151157
}
152158
for (ItemMetadata candidate : candidates) {
153-
if (ObjectUtils.nullSafeEquals(candidate.getSourceType(),
154-
metadata.getSourceType())) {
159+
if (nullSafeEquals(candidate.getSourceType(), metadata.getSourceType())) {
155160
return candidate;
156161
}
157162
}
158163
return null;
159164
}
160165

166+
private boolean nullSafeEquals(Object o1, Object o2) {
167+
if (o1 == o2) {
168+
return true;
169+
}
170+
return o1 != null && o2 != null && o1.equals(o2);
171+
}
172+
161173
public static String nestedPrefix(String prefix, String name) {
162174
String nestedPrefix = (prefix == null ? "" : prefix);
163175
String dashedName = toDashedCase(name);
@@ -185,8 +197,7 @@ else if (Character.isUpperCase(current) && previous != null
185197
return dashed.toString().toLowerCase();
186198
}
187199

188-
private static <T extends Comparable<T>> List<T> flattenValues(
189-
MultiValueMap<?, T> map) {
200+
private static <T extends Comparable<T>> List<T> flattenValues(Map<?, List<T>> map) {
190201
List<T> content = new ArrayList<T>();
191202
for (List<T> values : map.values()) {
192203
content.addAll(values);

0 commit comments

Comments
 (0)