|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.binding.mapping.MappingBuilder
public class MappingBuilder
A stateful builder that builds Mapping
objects. Designed for convenience to build mappings in a clear,
readable manner.
Example usage:
MappingBuilder mapping = new MappingBuilder(); Mapping result = mapping.source("foo").target("bar").from(String.class).to(Long.class).value();Calling the
value()
result method clears out this builder's state so it can be reused to build another
mapping.
Constructor Summary | |
---|---|
MappingBuilder(ExpressionParser expressionParser)
Creates a mapping builder that uses the expression parser to parse attribute mapping expressions. |
Method Summary | |
---|---|
MappingBuilder |
from(java.lang.Class sourceType)
Sets the expected type of the object returned by evaluating the source expression. |
MappingBuilder |
required()
Marks the mapping to be built a "required" mapping. |
void |
reset()
Reset this mapping builder. |
void |
setConversionService(ConversionService conversionService)
Sets the conversion service that will convert the object returned by evaluating the source expression to the to(Class) type if necessary. |
MappingBuilder |
source(java.lang.String expressionString)
Sets the source expression of the mapping built by this builder. |
MappingBuilder |
target(java.lang.String expressionString)
Sets the target property expression of the mapping built by this builder. |
MappingBuilder |
targetCollection(java.lang.String expressionString)
Sets the target collection of the mapping built by this builder. |
MappingBuilder |
to(java.lang.Class targetType)
Sets the target type of the property writeable by the target expression. |
Mapping |
value()
The logical GoF builder getResult method, returning a fully constructed Mapping from the configured pieces. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MappingBuilder(ExpressionParser expressionParser)
expressionParser
- the expression parserMethod Detail |
---|
public void setConversionService(ConversionService conversionService)
to(Class)
type if necessary.
conversionService
- the conversion servicepublic MappingBuilder source(java.lang.String expressionString)
expressionString
- the expression string
public MappingBuilder target(java.lang.String expressionString)
expressionString
- the expression string
public MappingBuilder targetCollection(java.lang.String expressionString)
expressionString
- the expression string, resolving a collection
public MappingBuilder from(java.lang.Class sourceType)
to(Class)
to perform a type conversion during the mapping process.
sourceType
- the source type
public MappingBuilder to(java.lang.Class targetType)
targetType
- the target type
public MappingBuilder required()
public Mapping value()
public void reset()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |