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
4f207d24
Commit
4f207d24
authored
Jan 02, 2019
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15595 from dreis2211
* pr/15595: Use JSONObject.putOpt in JsonConverter
parents
19caff67
46e59503
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
13 deletions
+6
-13
JsonConverter.java
...k/boot/configurationprocessor/metadata/JsonConverter.java
+6
-13
No files found.
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/JsonConverter.java
View file @
4f207d24
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
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.
...
...
@@ -62,10 +62,10 @@ class JsonConverter {
public
JSONObject
toJsonObject
(
ItemMetadata
item
)
throws
Exception
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"name"
,
item
.
getName
());
putIfPresent
(
jsonObject
,
"type"
,
item
.
getType
());
putIfPresent
(
jsonObject
,
"description"
,
item
.
getDescription
());
putIfPresent
(
jsonObject
,
"sourceType"
,
item
.
getSourceType
());
putIfPresent
(
jsonObject
,
"sourceMethod"
,
item
.
getSourceMethod
());
jsonObject
.
putOpt
(
"type"
,
item
.
getType
());
jsonObject
.
putOpt
(
"description"
,
item
.
getDescription
());
jsonObject
.
putOpt
(
"sourceType"
,
item
.
getSourceType
());
jsonObject
.
putOpt
(
"sourceMethod"
,
item
.
getSourceMethod
());
Object
defaultValue
=
item
.
getDefaultValue
();
if
(
defaultValue
!=
null
)
{
putDefaultValue
(
jsonObject
,
defaultValue
);
...
...
@@ -111,7 +111,7 @@ class JsonConverter {
private
JSONObject
getItemHintValue
(
ItemHint
.
ValueHint
value
)
throws
Exception
{
JSONObject
result
=
new
JSONObject
();
putHintValue
(
result
,
value
.
getValue
());
putIfPresent
(
result
,
"description"
,
value
.
getDescription
());
result
.
putOpt
(
"description"
,
value
.
getDescription
());
return
result
;
}
...
...
@@ -137,13 +137,6 @@ class JsonConverter {
return
result
;
}
private
void
putIfPresent
(
JSONObject
jsonObject
,
String
name
,
Object
value
)
throws
Exception
{
if
(
value
!=
null
)
{
jsonObject
.
put
(
name
,
value
);
}
}
private
void
putHintValue
(
JSONObject
jsonObject
,
Object
value
)
throws
Exception
{
Object
hintValue
=
extractItemValue
(
value
);
jsonObject
.
put
(
"value"
,
hintValue
);
...
...
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