Skip to content

Commit 0a5ed38

Browse files
committed
Added UUID support
1 parent 2ee930e commit 0a5ed38

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/org/javawebstack/abstractdata/mapper/DefaultMappers.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ public static class FallbackMapper implements MapperTypeAdapter {
266266
public AbstractElement toAbstract(MapperContext context, Object value) throws MapperException {
267267
if(value.getClass().isEnum())
268268
return new AbstractPrimitive(((Enum<?>) value).name());
269+
if(value.getClass().equals(UUID.class))
270+
return new AbstractPrimitive(value.toString());
269271
MapperTypeSpec spec = MapperTypeSpec.get(value.getClass());
270272
if(spec == null)
271273
throw new MapperException("Unmappable type '" + value.getClass().getName() + "'");
@@ -298,6 +300,8 @@ public Object fromAbstract(MapperContext context, AbstractElement element, Class
298300
throw new MapperException("There is no enum constant '" + element.string() + "'");
299301
}
300302
}
303+
if(type.equals(UUID.class))
304+
return UUID.fromString(element.string());
301305
if(!element.isObject())
302306
throw new MapperWrongTypeException(context.getField().getName(), "object", Helpers.typeName(element));
303307
MapperTypeSpec spec = MapperTypeSpec.get(type);

0 commit comments

Comments
 (0)