Added targetCollection(String) method to MappingBuilder.

This commit is contained in:
Erwin Vervaet
2007-05-30 13:23:08 +00:00
parent 518a20019b
commit 3a1fa5c30a
2 changed files with 14 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ import org.springframework.binding.convert.support.DefaultConversionService;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionParser;
import org.springframework.binding.expression.SettableExpression;
import org.springframework.binding.expression.support.CollectionAddingExpression;
import org.springframework.util.Assert;
/**
@@ -38,6 +39,7 @@ import org.springframework.util.Assert;
* it can be reused to build another mapping.
*
* @author Keith Donald
* @author Erwin Vervaet
*/
public class MappingBuilder {
@@ -116,6 +118,17 @@ public class MappingBuilder {
return this;
}
/**
* Sets the target collection of the mapping built by this builder.
* @param expressionString the expression string, resolving a collection
* @return this, to support call-chaining
*/
public MappingBuilder targetCollection(String expressionString) {
targetExpression = new CollectionAddingExpression(
expressionParser.parseSettableExpression(expressionString));
return this;
}
/**
* Sets the expected type of the object returned by evaluating the source
* expression. Used in conjunction with {@link #to(Class)} to perform a type