Commit 943d0c49 by Tuomas Riihimäki

GenericIntegerEntityConvert to support null values...

1 parent 46437a83
...@@ -58,10 +58,16 @@ public abstract class GenericIntegerEntityConverter<T extends ModelInterface<Int ...@@ -58,10 +58,16 @@ public abstract class GenericIntegerEntityConverter<T extends ModelInterface<Int
T ret = null; T ret = null;
Integer id = null; Integer id = null;
if (value != null) { if (value != null) {
try {
id = Integer.parseInt(value); id = Integer.parseInt(value);
if (id != null) { if (id != null) {
ret = find(id); ret = find(id);
} }
} catch (NumberFormatException nfe) {
if (value == null || !value.equals("null")) {
throw nfe;
}
}
} }
logger.debug("Converted String {} to Integer {} became object {}", new Object[] { value, id, ret }); logger.debug("Converted String {} to Integer {} became object {}", new Object[] { value, id, ret });
return ret; return ret;
...@@ -78,6 +84,10 @@ public abstract class GenericIntegerEntityConverter<T extends ModelInterface<Int ...@@ -78,6 +84,10 @@ public abstract class GenericIntegerEntityConverter<T extends ModelInterface<Int
ret = entity.getId().toString(); ret = entity.getId().toString();
} }
} }
if (ret == null)
{
ret = "null";
}
return ret; return ret;
} }
// //
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!