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
50920190
Commit
50920190
authored
Dec 03, 2014
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish default value for arrays
See gh-1996
parent
f821fdff
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
3 deletions
+11
-3
appendix-configuration-metadata.adoc
...cs/src/main/asciidoc/appendix-configuration-metadata.adoc
+3
-2
JavaCompilerFieldValuesParser.java
...ssor/fieldvalues/javac/JavaCompilerFieldValuesParser.java
+5
-1
AbstractFieldValuesProcessorTests.java
...cessor/fieldvalues/AbstractFieldValuesProcessorTests.java
+1
-0
FieldValues.java
...ork/boot/configurationsample/fieldvalues/FieldValues.java
+2
-0
No files found.
spring-boot-docs/src/main/asciidoc/appendix-configuration-metadata.adoc
View file @
50920190
...
@@ -144,8 +144,9 @@ The JSON object contained in the `properties` array can contain the following at
...
@@ -144,8 +144,9 @@ The JSON object contained in the `properties` array can contain the following at
|`defaultValue`
|`defaultValue`
| Object
| Object
| The default value which will be used if the property is not specified. May be omitted
| The default value which will be used if the property is not specified. Can also be an
if the default value is not known.
array of value(s) if the type of the property is an array. May be omitted if the default
value is not known.
|`deprecated`
|`deprecated`
| boolean
| boolean
...
...
spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/JavaCompilerFieldValuesParser.java
View file @
50920190
...
@@ -124,7 +124,11 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
...
@@ -124,7 +124,11 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
if
(
arrayValues
!=
null
)
{
if
(
arrayValues
!=
null
)
{
Object
[]
result
=
new
Object
[
arrayValues
.
size
()];
Object
[]
result
=
new
Object
[
arrayValues
.
size
()];
for
(
int
i
=
0
;
i
<
arrayValues
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
arrayValues
.
size
();
i
++)
{
result
[
i
]
=
getValue
(
arrayValues
.
get
(
i
),
null
);
Object
value
=
getValue
(
arrayValues
.
get
(
i
),
null
);
if
(
value
==
null
)
{
// One of the elements could not be resolved
return
defaultValue
;
}
result
[
i
]
=
value
;
}
}
return
result
;
return
result
;
}
}
...
...
spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/fieldvalues/AbstractFieldValuesProcessorTests.java
View file @
50920190
...
@@ -84,6 +84,7 @@ public abstract class AbstractFieldValuesProcessorTests {
...
@@ -84,6 +84,7 @@ public abstract class AbstractFieldValuesProcessorTests {
assertThat
(
values
.
get
(
"stringArrayConst"
),
equalToObject
(
new
Object
[]{
"OK"
,
"KO"
}));
assertThat
(
values
.
get
(
"stringArrayConst"
),
equalToObject
(
new
Object
[]{
"OK"
,
"KO"
}));
assertThat
(
values
.
get
(
"stringArrayConstElements"
),
equalToObject
(
new
Object
[]
{
"c"
}));
assertThat
(
values
.
get
(
"stringArrayConstElements"
),
equalToObject
(
new
Object
[]
{
"c"
}));
assertThat
(
values
.
get
(
"integerArray"
),
equalToObject
(
new
Object
[]
{
42
,
24
}));
assertThat
(
values
.
get
(
"integerArray"
),
equalToObject
(
new
Object
[]
{
42
,
24
}));
assertThat
(
values
.
get
(
"unknownArray"
),
nullValue
());
}
}
private
Matcher
<
Object
>
equalToObject
(
Object
object
)
{
private
Matcher
<
Object
>
equalToObject
(
Object
object
)
{
...
...
spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/fieldvalues/FieldValues.java
View file @
50920190
...
@@ -90,4 +90,6 @@ public class FieldValues {
...
@@ -90,4 +90,6 @@ public class FieldValues {
private
Integer
[]
integerArray
=
new
Integer
[]
{
42
,
24
};
private
Integer
[]
integerArray
=
new
Integer
[]
{
42
,
24
};
private
FieldValues
[]
unknownArray
=
new
FieldValues
[]
{
new
FieldValues
()};
}
}
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