Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
ba6be4f2
Commit
ba6be4f2
authored
Jan 18, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
8704cf1f
71ab5dd7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
165 additions
and
0 deletions
+165
-0
TypeUtils.java
...pringframework/boot/configurationprocessor/TypeUtils.java
+6
-0
ConfigurationMetadataAnnotationProcessorTests.java
...cessor/ConfigurationMetadataAnnotationProcessorTests.java
+32
-0
SimpleArrayProperties.java
...oot/configurationsample/simple/SimpleArrayProperties.java
+75
-0
WildcardConfig.java
...ork/boot/configurationsample/specific/WildcardConfig.java
+52
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java
View file @
ba6be4f2
...
...
@@ -26,6 +26,7 @@ import java.util.stream.Collectors;
import
javax.annotation.processing.ProcessingEnvironment
;
import
javax.lang.model.element.Element
;
import
javax.lang.model.element.TypeElement
;
import
javax.lang.model.type.ArrayType
;
import
javax.lang.model.type.DeclaredType
;
import
javax.lang.model.type.PrimitiveType
;
import
javax.lang.model.type.TypeKind
;
...
...
@@ -197,6 +198,11 @@ class TypeUtils {
return
sb
.
toString
();
}
@Override
public
String
visitArray
(
ArrayType
t
,
Void
none
)
{
return
t
.
getComponentType
().
accept
(
this
,
none
)
+
"[]"
;
}
@Override
public
String
visitPrimitive
(
PrimitiveType
t
,
Void
none
)
{
return
this
.
types
.
boxedClass
(
t
).
getQualifiedName
().
toString
();
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java
View file @
ba6be4f2
...
...
@@ -62,6 +62,7 @@ import org.springframework.boot.configurationsample.simple.ClassWithNestedProper
import
org.springframework.boot.configurationsample.simple.DeprecatedSingleProperty
;
import
org.springframework.boot.configurationsample.simple.HierarchicalProperties
;
import
org.springframework.boot.configurationsample.simple.NotAnnotated
;
import
org.springframework.boot.configurationsample.simple.SimpleArrayProperties
;
import
org.springframework.boot.configurationsample.simple.SimpleCollectionProperties
;
import
org.springframework.boot.configurationsample.simple.SimplePrefixValueProperties
;
import
org.springframework.boot.configurationsample.simple.SimpleProperties
;
...
...
@@ -80,6 +81,7 @@ import org.springframework.boot.configurationsample.specific.InnerClassRootConfi
import
org.springframework.boot.configurationsample.specific.InvalidAccessorProperties
;
import
org.springframework.boot.configurationsample.specific.InvalidDoubleRegistrationProperties
;
import
org.springframework.boot.configurationsample.specific.SimplePojo
;
import
org.springframework.boot.configurationsample.specific.WildcardConfig
;
import
org.springframework.boot.testsupport.compiler.TestCompiler
;
import
org.springframework.util.FileCopyUtils
;
...
...
@@ -272,6 +274,22 @@ public class ConfigurationMetadataAnnotationProcessorTests {
"java.util.Map<java.lang.String,org.springframework.boot.configurationsample.simple.SimpleCollectionProperties.Holder<java.lang.String>>"
));
}
@Test
public
void
parseArrayConfig
()
throws
Exception
{
ConfigurationMetadata
metadata
=
compile
(
SimpleArrayProperties
.
class
);
assertThat
(
metadata
).
has
(
Metadata
.
withGroup
(
"array"
)
.
ofType
(
SimpleArrayProperties
.
class
));
assertThat
(
metadata
).
has
(
Metadata
.
withProperty
(
"array.primitive"
,
"java.lang.Integer[]"
));
assertThat
(
metadata
).
has
(
Metadata
.
withProperty
(
"array.simple"
,
"java.lang.String[]"
));
assertThat
(
metadata
).
has
(
Metadata
.
withProperty
(
"array.inner"
,
"org.springframework.boot.configurationsample.simple.SimpleArrayProperties$Holder[]"
));
assertThat
(
metadata
).
has
(
Metadata
.
withProperty
(
"array.name-to-integer"
,
"java.util.Map<java.lang.String,java.lang.Integer>[]"
));
assertThat
(
metadata
.
getItems
()).
hasSize
(
5
);
}
@Test
public
void
simpleMethodConfig
()
{
ConfigurationMetadata
metadata
=
compile
(
SimpleMethodConfig
.
class
);
...
...
@@ -482,6 +500,20 @@ public class ConfigurationMetadataAnnotationProcessorTests {
assertThat
(
metadata
.
getItems
()).
hasSize
(
9
);
}
@Test
public
void
wildcardTypes
()
throws
IOException
{
ConfigurationMetadata
metadata
=
compile
(
WildcardConfig
.
class
);
assertThat
(
metadata
).
has
(
Metadata
.
withGroup
(
"wildcard"
)
.
ofType
(
WildcardConfig
.
class
));
assertThat
(
metadata
).
has
(
Metadata
.
withProperty
(
"wildcard.string-to-number"
)
.
ofType
(
"java.util.Map<java.lang.String,? extends java.lang.Number>"
)
.
fromSource
(
WildcardConfig
.
class
));
assertThat
(
metadata
).
has
(
Metadata
.
withProperty
(
"wildcard.integers"
)
.
ofType
(
"java.util.List<? super java.lang.Integer>"
)
.
fromSource
(
WildcardConfig
.
class
));
assertThat
(
metadata
.
getItems
()).
hasSize
(
3
);
}
@Test
public
void
lombokDataProperties
()
{
ConfigurationMetadata
metadata
=
compile
(
LombokSimpleDataProperties
.
class
);
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/simple/SimpleArrayProperties.java
0 → 100644
View file @
ba6be4f2
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
configurationsample
.
simple
;
import
java.util.Map
;
import
org.springframework.boot.configurationsample.ConfigurationProperties
;
/**
* Properties with array.
*
* @author Stephane Nicoll
*/
@ConfigurationProperties
(
"array"
)
public
class
SimpleArrayProperties
{
private
int
[]
primitive
;
private
String
[]
simple
;
private
Holder
[]
inner
;
private
Map
<
String
,
Integer
>[]
nameToInteger
;
public
int
[]
getPrimitive
()
{
return
this
.
primitive
;
}
public
void
setPrimitive
(
int
[]
primitive
)
{
this
.
primitive
=
primitive
;
}
public
String
[]
getSimple
()
{
return
this
.
simple
;
}
public
void
setSimple
(
String
[]
simple
)
{
this
.
simple
=
simple
;
}
public
Holder
[]
getInner
()
{
return
this
.
inner
;
}
public
void
setInner
(
Holder
[]
inner
)
{
this
.
inner
=
inner
;
}
public
Map
<
String
,
Integer
>[]
getNameToInteger
()
{
return
this
.
nameToInteger
;
}
public
void
setNameToInteger
(
Map
<
String
,
Integer
>[]
nameToInteger
)
{
this
.
nameToInteger
=
nameToInteger
;
}
public
static
class
Holder
{
}
}
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/specific/WildcardConfig.java
0 → 100644
View file @
ba6be4f2
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
configurationsample
.
specific
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.boot.configurationsample.ConfigurationProperties
;
/**
* Demonstrate properties with a wildcard type.
*
* @author Stephane Nicoll
*/
@ConfigurationProperties
(
"wildcard"
)
public
class
WildcardConfig
{
private
Map
<
String
,
?
extends
Number
>
stringToNumber
;
private
List
<?
super
Integer
>
integers
;
public
Map
<
String
,
?
extends
Number
>
getStringToNumber
()
{
return
this
.
stringToNumber
;
}
public
void
setStringToNumber
(
Map
<
String
,
?
extends
Number
>
stringToNumber
)
{
this
.
stringToNumber
=
stringToNumber
;
}
public
List
<?
super
Integer
>
getIntegers
()
{
return
this
.
integers
;
}
public
void
setIntegers
(
List
<?
super
Integer
>
integers
)
{
this
.
integers
=
integers
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment