#439 - @EnumValue("01") stored as integer rather than string - ENum stores strings as numerics?

This commit is contained in:
Robin Bygrave
2015-10-28 08:53:14 +13:00
parent a30948d38d
commit 3d62f58930
2 changed files with 46 additions and 2 deletions
@@ -419,8 +419,10 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable {
return value;
}
@SuppressWarnings("ResultOfMethodCallIgnored")
private boolean isIntegerType(String s) {
protected boolean isIntegerType(String s) {
if (isLeadingZeros(s)) {
return false;
}
try {
Integer.parseInt(s);
return true;
@@ -429,6 +431,13 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable {
}
}
/**
* Treat leading zeros as a non-integer for enum values.
*/
private boolean isLeadingZeros(String s) {
return s.length() > 1 && s.charAt(0) == '0';
}
/**
* Create the Mapping of Enum fields to DB values using EnumValue annotations.
* <p>