IntegerConverter implements Converter { @SuppressWarnings("rawtypes") public Object convert(Class destClass, Object srcObj) { if (Boolean.class.isAssignableFrom(srcObj.getClass())) { boolean value = (Boolean)srcObj; return value ? 1 : 0; } else if (MappingUtils.isEnumType(srcObj.getClass())) { return ((Enum)srcObj).ordinal(); } else { return commonsConverter.convert(destClass, srcObj); } }  @SuppressWarnings("rawtypes") Object convert(Class destClass, Object srcObj);  }
@Test public void testConvert() { assertEquals(new Integer(1), converter.convert(Integer.class, Boolean.TRUE)); assertEquals(new Integer(0), converter.convert(Integer.class, Boolean.FALSE)); assertEquals(new Integer(100), converter.convert(Integer.class, "100")); }