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
26cc6285
Commit
26cc6285
authored
Aug 04, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.1.x'
parents
a7338e18
0c6a0bde
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
4 deletions
+36
-4
spring
spring-boot-cli/src/main/executablecontent/bin/spring
+1
-1
RelaxedDataBinder.java
...java/org/springframework/boot/bind/RelaxedDataBinder.java
+13
-3
RelaxedDataBinderTests.java
...org/springframework/boot/bind/RelaxedDataBinderTests.java
+22
-0
No files found.
spring-boot-cli/src/main/executablecontent/bin/spring
View file @
26cc6285
...
...
@@ -69,7 +69,7 @@ if [ -z "${SPRING_HOME}" ]; then
done
SAVED
=
"
`
pwd
`
"
cd
"
`
dirname
\"
$PRG
\"
`
/../"
>
&-
SPRING_HOME
=
"
`
pwd
-P
`
"
export
SPRING_HOME
=
"
`
pwd
-P
`
"
cd
"
$SAVED
"
>
&-
fi
...
...
spring-boot/src/main/java/org/springframework/boot/bind/RelaxedDataBinder.java
View file @
26cc6285
...
...
@@ -28,6 +28,7 @@ import org.springframework.beans.BeanWrapperImpl;
import
org.springframework.beans.InvalidPropertyException
;
import
org.springframework.beans.MutablePropertyValues
;
import
org.springframework.beans.PropertyValue
;
import
org.springframework.core.convert.ConversionService
;
import
org.springframework.core.convert.TypeDescriptor
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.DataBinder
;
...
...
@@ -47,6 +48,8 @@ public class RelaxedDataBinder extends DataBinder {
private
boolean
ignoreNestedProperties
;
private
ConversionService
relaxedConversionService
;
/**
* Create a new {@link RelaxedDataBinder} instance.
* @param target the target into which properties are bound
...
...
@@ -76,12 +79,19 @@ public class RelaxedDataBinder extends DataBinder {
this
.
ignoreNestedProperties
=
ignoreNestedProperties
;
}
@Override
public
void
setConversionService
(
ConversionService
conversionService
)
{
super
.
setConversionService
(
conversionService
);
this
.
relaxedConversionService
=
new
RelaxedConversionService
(
getConversionService
());
}
@Override
public
void
initBeanPropertyAccess
()
{
super
.
initBeanPropertyAccess
();
this
.
relaxedConversionService
=
(
this
.
relaxedConversionService
!=
null
?
this
.
relaxedConversionService
:
new
RelaxedConversionService
(
getConversionService
()));
// Hook in the RelaxedConversionService
getInternalBindingResult
().
initConversion
(
new
RelaxedConversionService
(
getConversionService
()));
getInternalBindingResult
().
initConversion
(
relaxedConversionService
);
}
@Override
...
...
@@ -111,6 +121,7 @@ public class RelaxedDataBinder extends DataBinder {
}
BeanWrapper
targetWrapper
=
new
BeanWrapperImpl
(
target
);
targetWrapper
.
setConversionService
(
this
.
relaxedConversionService
);
targetWrapper
.
setAutoGrowNestedPaths
(
true
);
List
<
PropertyValue
>
list
=
propertyValues
.
getPropertyValueList
();
...
...
@@ -189,7 +200,6 @@ public class RelaxedDataBinder extends DataBinder {
TypeDescriptor
descriptor
=
wrapper
.
getPropertyTypeDescriptor
(
name
);
if
(
descriptor
==
null
||
descriptor
.
isMap
())
{
if
(
descriptor
!=
null
)
{
wrapper
.
getPropertyValue
(
name
+
"[foo]"
);
TypeDescriptor
valueDescriptor
=
descriptor
.
getMapValueTypeDescriptor
();
if
(
valueDescriptor
!=
null
)
{
Class
<?>
valueType
=
valueDescriptor
.
getObjectType
();
...
...
spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java
View file @
26cc6285
...
...
@@ -284,6 +284,15 @@ public class RelaxedDataBinderTests {
assertEquals
(
"123"
,
target
.
getNested
().
get
(
"value.foo"
));
}
@Test
public
void
testBindNestedMapOfEnum
()
throws
Exception
{
this
.
conversionService
=
new
DefaultConversionService
();
TargetWithNestedMapOfEnum
target
=
new
TargetWithNestedMapOfEnum
();
bind
(
target
,
"nested.this: bar\n"
+
"nested.ThAt: 123"
);
assertEquals
(
"bar"
,
target
.
getNested
().
get
(
Bingo
.
THIS
));
assertEquals
(
"123"
,
target
.
getNested
().
get
(
Bingo
.
THAT
));
}
@Test
public
void
testBindNestedMapBracketReferenced
()
throws
Exception
{
TargetWithNestedMap
target
=
new
TargetWithNestedMap
();
...
...
@@ -578,6 +587,19 @@ public class RelaxedDataBinderTests {
}
public
static
class
TargetWithNestedMapOfEnum
{
private
Map
<
Bingo
,
Object
>
nested
;
public
Map
<
Bingo
,
Object
>
getNested
()
{
return
nested
;
}
public
void
setNested
(
Map
<
Bingo
,
Object
>
nested
)
{
this
.
nested
=
nested
;
}
}
public
static
class
TargetWithNestedMapOfListOfString
{
private
Map
<
String
,
List
<
String
>>
nested
;
...
...
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