DATACMNS-1101 - Alias is no longer based on Optional.

Remove internal Optional usage from Alias so it's a pure value object that does not create Optional instances during its usage.
This commit is contained in:
Mark Paluch
2017-06-28 14:36:10 +02:00
committed by Oliver Gierke
parent 78e8327d2d
commit 8c499122c7
3 changed files with 110 additions and 14 deletions

View File

@@ -36,6 +36,7 @@ import org.springframework.util.Assert;
* @author Oliver Gierke
* @author Thomas Darimont
* @author Christoph Strobl
* @author Mark Paluch
*/
public class DefaultTypeMapper<S> implements TypeMapper<S> {
@@ -198,7 +199,7 @@ public class DefaultTypeMapper<S> implements TypeMapper<S> {
Alias alias = getAliasFor(info);
if (alias.isPresent()) {
accessor.writeTypeTo(sink, alias.getValue().get());
accessor.writeTypeTo(sink, alias.getValue());
}
}

View File

@@ -48,8 +48,13 @@ public class SimpleTypeInformationMapper implements TypeInformationMapper {
@Override
public TypeInformation<?> resolveTypeFrom(Alias alias) {
return alias.mapTyped(String.class)//
.flatMap(it -> CACHE.computeIfAbsent(it, SimpleTypeInformationMapper::loadClass)).orElse(null);
String stringAlias = alias.mapTyped(String.class);
if (stringAlias != null) {
return CACHE.computeIfAbsent(stringAlias, SimpleTypeInformationMapper::loadClass).orElse(null);
}
return null;
}
/**