提交 e4c868b8 编写于 作者: K Keith Donald

javadoc

上级 84bdd1ab
......@@ -295,12 +295,6 @@ public class GenericBinder implements Binder {
"Unable to get model binding; cannot parse property expression from property string ["
+ 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());
}
......@@ -694,7 +688,7 @@ public class GenericBinder implements Binder {
builder.arg("label", new ResolvableArgument(property));
builder.arg("value", sourceValue);
builder.defaultMessage("Successfully bound user value " + StylerUtils.style(sourceValue)
+ "to property '" + property + "'");
+ " to property '" + property + "'");
return builder.build();
}
};
......
......@@ -264,7 +264,7 @@ public class GenericBinderTests {
binder.registerFormatter(new GenericCollectionPropertyType(List.class, Address.class), new AddressListFormatter());
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");
binder.bind(values);
BindingResults results = binder.bind(values);
Assert.assertEquals(3, bean.addresses.size());
assertEquals("4655 Macy Lane", bean.addresses.get(0).street);
assertEquals("Melbourne", bean.addresses.get(0).city);
......
......@@ -159,29 +159,69 @@ public class GenericTypeConverter implements TypeConverter, ConverterRegistry {
+ "request an interface or concrete implementation instead");
}
return new ArrayToCollection(sourceType, targetType, this);
}
}
if (targetType.isArray()) {
if (sourceType.isCollection()) {
return new CollectionToArray(sourceType, targetType, this);
} else if (targetType.isMap()) {
if (sourceType.getElementType().equals(String.class)) {
// string array to map; with string element values in format foo=bar
return null;
} else {
return null;
}
} else {
// array to object
return null;
}
}
if (sourceType.isCollection()) {
if (targetType.isCollection()) {
if (targetType.isCollection()) {
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 {
return null;
}
} else {
// collection to object
return null;
}
}
if (sourceType.isMap()) {
if (targetType.isMap()) {
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 {
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)) {
return NoOpConversionExecutor.INSTANCE;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册