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
20d39f7a
Commit
20d39f7a
authored
Jun 15, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
818d3bd2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
26 deletions
+26
-26
VcapApplicationListener.java
...gframework/boot/cloudfoundry/VcapApplicationListener.java
+26
-26
No files found.
spring-boot/src/main/java/org/springframework/boot/cloudfoundry/VcapApplicationListener.java
View file @
20d39f7a
...
...
@@ -193,49 +193,49 @@ public class VcapApplicationListener implements
}
}
@SuppressWarnings
(
"unchecked"
)
private
void
flatten
(
Properties
properties
,
Map
<
String
,
Object
>
input
,
String
path
)
{
for
(
Entry
<
String
,
Object
>
entry
:
input
.
entrySet
())
{
String
key
=
entry
.
getKey
();
if
(
StringUtils
.
hasText
(
path
))
{
if
(
key
.
startsWith
(
"["
))
{
key
=
path
+
key
;
}
else
{
key
=
path
+
"."
+
key
;
}
}
String
key
=
getFullKey
(
path
,
entry
.
getKey
());
Object
value
=
entry
.
getValue
();
if
(
value
instanceof
String
)
{
properties
.
put
(
key
,
value
);
}
else
if
(
value
instanceof
Number
)
{
properties
.
put
(
key
,
value
.
toString
());
}
else
if
(
value
instanceof
Boolean
)
{
properties
.
put
(
key
,
value
.
toString
());
}
else
if
(
value
instanceof
Map
)
{
if
(
value
instanceof
Map
)
{
// Need a compound key
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
value
;
flatten
(
properties
,
map
,
key
);
flatten
(
properties
,
(
Map
<
String
,
Object
>)
value
,
key
);
}
else
if
(
value
instanceof
Collection
)
{
// Need a compound key
@SuppressWarnings
(
"unchecked"
)
Collection
<
Object
>
collection
=
(
Collection
<
Object
>)
value
;
properties
.
put
(
key
,
StringUtils
.
collectionToCommaDelimitedString
(
collection
));
int
count
=
0
;
for
(
Object
object
:
collection
)
{
flatten
(
properties
,
Collections
.
singletonMap
(
"["
+
(
count
++)
+
"]"
,
object
),
key
);
for
(
Object
item
:
collection
)
{
String
itemKey
=
"["
+
(
count
++)
+
"]"
;
flatten
(
properties
,
Collections
.
singletonMap
(
itemKey
,
item
),
key
);
}
}
else
if
(
value
instanceof
String
)
{
properties
.
put
(
key
,
value
);
}
else
if
(
value
instanceof
Number
)
{
properties
.
put
(
key
,
value
.
toString
());
}
else
if
(
value
instanceof
Boolean
)
{
properties
.
put
(
key
,
value
.
toString
());
}
else
{
properties
.
put
(
key
,
value
==
null
?
""
:
value
);
}
}
}
private
String
getFullKey
(
String
path
,
String
key
)
{
if
(!
StringUtils
.
hasText
(
path
))
{
return
key
;
}
if
(
key
.
startsWith
(
"["
))
{
return
path
+
key
;
}
return
path
+
"."
+
key
;
}
}
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