diff --git a/spring-boot-tools/spring-boot-configuration-processor/pom.xml b/spring-boot-tools/spring-boot-configuration-processor/pom.xml
index 10466451a1..805f3ac7c8 100644
--- a/spring-boot-tools/spring-boot-configuration-processor/pom.xml
+++ b/spring-boot-tools/spring-boot-configuration-processor/pom.xml
@@ -29,10 +29,6 @@
lombok
test
-
- org.springframework
- spring-core
-
diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java
index be735020dc..2144292fd0 100644
--- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java
+++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java
@@ -20,15 +20,12 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.ListIterator;
+import java.util.Map;
import java.util.Set;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-import org.springframework.util.ObjectUtils;
-
/**
* Configuration meta-data.
*
@@ -46,18 +43,18 @@ public class ConfigurationMetadata {
SEPARATORS = Collections.unmodifiableSet(new HashSet(chars));
}
- private final MultiValueMap items;
+ private final Map> items;
- private final MultiValueMap hints;
+ private final Map> hints;
public ConfigurationMetadata() {
- this.items = new LinkedMultiValueMap();
- this.hints = new LinkedMultiValueMap();
+ this.items = new LinkedHashMap>();
+ this.hints = new LinkedHashMap>();
}
public ConfigurationMetadata(ConfigurationMetadata metadata) {
- this.items = new LinkedMultiValueMap(metadata.items);
- this.hints = new LinkedMultiValueMap(metadata.hints);
+ this.items = new LinkedHashMap>(metadata.items);
+ this.hints = new LinkedHashMap>(metadata.hints);
}
/**
@@ -65,7 +62,7 @@ public class ConfigurationMetadata {
* @param itemMetadata the meta-data to add
*/
public void add(ItemMetadata itemMetadata) {
- this.items.add(itemMetadata.getName(), itemMetadata);
+ add(this.items, itemMetadata.getName(), itemMetadata);
}
/**
@@ -73,7 +70,7 @@ public class ConfigurationMetadata {
* @param itemHint the item hint to add
*/
public void add(ItemHint itemHint) {
- this.hints.add(itemHint.getName(), itemHint);
+ add(this.hints, itemHint.getName(), itemHint);
}
/**
@@ -131,13 +128,22 @@ public class ConfigurationMetadata {
}
}
else {
- this.items.add(metadata.getName(), metadata);
+ add(this.items, metadata.getName(), metadata);
+ }
+ }
+
+ private void add(Map> map, K key, V value) {
+ List values = map.get(key);
+ if (values == null) {
+ values = new ArrayList();
+ map.put(key, values);
}
+ values.add(value);
}
private ItemMetadata findMatchingItemMetadata(ItemMetadata metadata) {
List candidates = this.items.get(metadata.getName());
- if (CollectionUtils.isEmpty(candidates)) {
+ if (candidates == null || candidates.isEmpty()) {
return null;
}
ListIterator it = candidates.listIterator();
@@ -150,14 +156,20 @@ public class ConfigurationMetadata {
return candidates.get(0);
}
for (ItemMetadata candidate : candidates) {
- if (ObjectUtils.nullSafeEquals(candidate.getSourceType(),
- metadata.getSourceType())) {
+ if (nullSafeEquals(candidate.getSourceType(), metadata.getSourceType())) {
return candidate;
}
}
return null;
}
+ private boolean nullSafeEquals(Object o1, Object o2) {
+ if (o1 == o2) {
+ return true;
+ }
+ return o1 != null && o2 != null && o1.equals(o2);
+ }
+
public static String nestedPrefix(String prefix, String name) {
String nestedPrefix = (prefix == null ? "" : prefix);
String dashedName = toDashedCase(name);
@@ -185,8 +197,7 @@ public class ConfigurationMetadata {
return dashed.toString().toLowerCase();
}
- private static > List flattenValues(
- MultiValueMap, T> map) {
+ private static > List flattenValues(Map, List> map) {
List content = new ArrayList();
for (List values : map.values()) {
content.addAll(values);