diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java index 8bf3cb28ee..8f40ce7796 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 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. @@ -19,6 +19,7 @@ package org.springframework.boot.configurationprocessor; import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import javax.annotation.processing.ProcessingEnvironment; @@ -186,7 +187,21 @@ class TypeUtils { return getQualifiedName(enclosingElement) + "$" + type.asElement().getSimpleName().toString(); } - return type.toString(); + StringBuilder sb = new StringBuilder(); + sb.append(getQualifiedName(type.asElement())); + if (!type.getTypeArguments().isEmpty()) { + sb.append("<"); + Iterator it = type.getTypeArguments().iterator(); + while (it.hasNext()) { + sb.append(it.next()); + if (it.hasNext()) { + sb.append(","); + } + } + sb.append(">"); + + } + return sb.toString(); } @Override diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java index d0f0bc9cfc..3496fb7ec9 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java @@ -252,6 +252,8 @@ public class ConfigurationMetadataAnnotationProcessorTests { "java.util.Collection")); assertThat(metadata).has(Metadata.withProperty("collection.doubles", "java.util.List")); + assertThat(metadata).has(Metadata.withProperty("collection.names-to-holders", + "java.util.Map>")); } @Test diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/simple/SimpleCollectionProperties.java b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/simple/SimpleCollectionProperties.java index 91d14019a2..732129ae4c 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/simple/SimpleCollectionProperties.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/simple/SimpleCollectionProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2018 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. @@ -45,6 +45,8 @@ public class SimpleCollectionProperties { private final List doubles = new ArrayList(); + private final Map> namesToHolders = new HashMap>(); + public Map getIntegersToNames() { return this.integersToNames; } @@ -81,4 +83,18 @@ public class SimpleCollectionProperties { return this.doubles; } + public Map> getNamesToHolders() { + return this.namesToHolders; + } + + public static class Holder { + + private T target; + + public void setTarget(T target) { + this.target = target; + } + + } + }