First fetch from the backingMap.

This commit is contained in:
Greg Burd 2017-09-29 09:47:15 -04:00
parent 265947586c
commit bf1d5f217f
2 changed files with 11 additions and 8 deletions

View file

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.helenus</groupId>
<artifactId>helenus-net-core</artifactId>
<version>2.0.47-SNAPSHOT</version>
<version>2.0.48-SNAPSHOT</version>
<packaging>jar</packaging>
<name>helenus</name>

View file

@ -28,18 +28,21 @@ public abstract class AbstractEntityDraft<E> implements Drafted<E> {
public E build() { return Helenus.map(getEntityClass(), toMap()); }
protected <T> T get(String key, Class<?> returnType) {
T value = (T) entityMap.get(key);
T value = (T) backingMap.get(key);
if (value == null) {
value = (T) entityMap.get(key);
if (value == null) {
if (Primitives.allPrimitiveTypes().contains(returnType)) {
if (Primitives.allPrimitiveTypes().contains(returnType)) {
DefaultPrimitiveTypes type = DefaultPrimitiveTypes.lookup(returnType);
if (type == null) {
throw new RuntimeException("unknown primitive type " + returnType);
DefaultPrimitiveTypes type = DefaultPrimitiveTypes.lookup(returnType);
if (type == null) {
throw new RuntimeException("unknown primitive type " + returnType);
}
return (T) type.getDefaultValue();
}
return (T) type.getDefaultValue();
}
}