DATACMNS-349 - Opened up SPI in DefaultTypeMapper to allow subclasses to resolve TypeAliases.

Added getAliasFor(TypeInformation) method in DefaultTypeMapper to allow subclasses to resolve TypeAliases.
This commit is contained in:
Thomas Darimont
2013-07-23 12:29:40 +02:00
committed by Oliver Gierke
parent 2afb570729
commit cc576a7398
2 changed files with 39 additions and 9 deletions

View File

@@ -35,6 +35,7 @@ import org.springframework.util.Assert;
* respectively.
*
* @author Oliver Gierke
* @author Thomas Darimont
*/
public class DefaultTypeMapper<S> implements TypeMapper<S> {
@@ -193,12 +194,30 @@ public class DefaultTypeMapper<S> implements TypeMapper<S> {
Assert.notNull(info);
Object alias = getAliasFor(info);
if (alias != null) {
accessor.writeTypeTo(sink, alias);
}
}
/**
* Returns the alias to be used for the given {@link TypeInformation}.
*
* @param info must not be {@literal null}
* @return the alias for the given {@link TypeInformation} or {@literal null} of none was found or all mappers
* returned {@literal null}.
*/
protected final Object getAliasFor(TypeInformation<?> info) {
Assert.notNull(info);
for (TypeInformationMapper mapper : mappers) {
Object alias = mapper.createAliasFor(info);
if (alias != null) {
accessor.writeTypeTo(sink, alias);
return;
return alias;
}
}
return null;
}
}