javadoc
This commit is contained in:
parent
84bdd1ab8e
commit
e4c868b837
|
|
@ -295,12 +295,6 @@ public class GenericBinder implements Binder {
|
||||||
"Unable to get model binding; cannot parse property expression from property string ["
|
"Unable to get model binding; cannot parse property expression from property string ["
|
||||||
+ property + "]", e);
|
+ property + "]", e);
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
propertyExpression.getValueType(createEvaluationContext());
|
|
||||||
} catch (EvaluationException e) {
|
|
||||||
throw new IllegalArgumentException("Unable to get model binding; cannot access property '"
|
|
||||||
+ propertyExpression.getExpressionString() + "'", e);
|
|
||||||
}
|
|
||||||
return new BindingImpl(propertyExpression, configuration.getFormatter());
|
return new BindingImpl(propertyExpression, configuration.getFormatter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ public class GenericBinderTests {
|
||||||
binder.registerFormatter(new GenericCollectionPropertyType(List.class, Address.class), new AddressListFormatter());
|
binder.registerFormatter(new GenericCollectionPropertyType(List.class, Address.class), new AddressListFormatter());
|
||||||
Map<String, String> values = new LinkedHashMap<String, String>();
|
Map<String, String> values = new LinkedHashMap<String, String>();
|
||||||
values.put("addresses", "4655 Macy Lane:Melbourne:FL:35452,1234 Rostock Circle:Palm Bay:FL:32901,1977 Bel Aire Estates:Coker:AL:12345");
|
values.put("addresses", "4655 Macy Lane:Melbourne:FL:35452,1234 Rostock Circle:Palm Bay:FL:32901,1977 Bel Aire Estates:Coker:AL:12345");
|
||||||
binder.bind(values);
|
BindingResults results = binder.bind(values);
|
||||||
Assert.assertEquals(3, bean.addresses.size());
|
Assert.assertEquals(3, bean.addresses.size());
|
||||||
assertEquals("4655 Macy Lane", bean.addresses.get(0).street);
|
assertEquals("4655 Macy Lane", bean.addresses.get(0).street);
|
||||||
assertEquals("Melbourne", bean.addresses.get(0).city);
|
assertEquals("Melbourne", bean.addresses.get(0).city);
|
||||||
|
|
|
||||||
|
|
@ -159,28 +159,68 @@ public class GenericTypeConverter implements TypeConverter, ConverterRegistry {
|
||||||
+ "request an interface or concrete implementation instead");
|
+ "request an interface or concrete implementation instead");
|
||||||
}
|
}
|
||||||
return new ArrayToCollection(sourceType, targetType, this);
|
return new ArrayToCollection(sourceType, targetType, this);
|
||||||
}
|
} else if (targetType.isMap()) {
|
||||||
}
|
if (sourceType.getElementType().equals(String.class)) {
|
||||||
if (targetType.isArray()) {
|
// string array to map; with string element values in format foo=bar
|
||||||
if (sourceType.isCollection()) {
|
return null;
|
||||||
return new CollectionToArray(sourceType, targetType, this);
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// array to object
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (sourceType.isCollection()) {
|
if (sourceType.isCollection()) {
|
||||||
if (targetType.isCollection()) {
|
if (targetType.isCollection()) {
|
||||||
return new CollectionToCollection(sourceType, targetType, this);
|
return new CollectionToCollection(sourceType, targetType, this);
|
||||||
|
} else if (targetType.isArray()) {
|
||||||
|
return new CollectionToArray(sourceType, targetType, this);
|
||||||
|
} else if (targetType.isMap()) {
|
||||||
|
if (sourceType.getElementType().equals(String.class)) {
|
||||||
|
// string collection to map; with string element values in format foo=bar
|
||||||
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// collection to object
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (sourceType.isMap()) {
|
if (sourceType.isMap()) {
|
||||||
if (targetType.isMap()) {
|
if (targetType.isMap()) {
|
||||||
return new MapToMap(sourceType, targetType, this);
|
return new MapToMap(sourceType, targetType, this);
|
||||||
|
} else if (targetType.isArray()) {
|
||||||
|
if (targetType.getElementType().equals(String.class)) {
|
||||||
|
// map to string array; with string element values in format foo=bar
|
||||||
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} else if (targetType.isCollection()) {
|
||||||
|
if (targetType.getElementType().equals(String.class)) {
|
||||||
|
// map to string collection; with string element values in format foo=bar
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// map to object
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (targetType.isArray()) {
|
||||||
|
// object to array
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (targetType.isCollection()) {
|
||||||
|
// object to collection
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (targetType.isMap()) {
|
||||||
|
// object to map
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
if (sourceType.isAssignableTo(targetType)) {
|
if (sourceType.isAssignableTo(targetType)) {
|
||||||
return NoOpConversionExecutor.INSTANCE;
|
return NoOpConversionExecutor.INSTANCE;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue