Permalink
Browse files

Enhance PropertyUtils.setProperty to convert 0/1 to Booleans if needed

git-svn-id: https://svn.apache.org/repos/asf/cayenne/main/trunk@1479928 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
johnthuss committed May 7, 2013
1 parent 37e132b commit 0649da49c14dd0d07ba2a5fb171d533376f9ad09
@@ -64,6 +64,11 @@ Object convert(Object object, Class<?> type) {
if (object instanceof Boolean) {
return object;
+ } else if (object instanceof Integer || object instanceof Long || object instanceof Short) {
+ if (((Number)object).longValue() == 0)
+ return Boolean.FALSE;
+ else if (((Number)object).longValue() == 1)
+ return Boolean.TRUE;
}
return "true".equalsIgnoreCase(object.toString())

0 comments on commit 0649da4

Please sign in to comment.