Sets all int fields in an object to 0.
try {
Field[] fields = obj.getClass()
.getDeclaredFields();
for (int idx = 0; idx < fields.length; idx++) {
if (fields[idx].getType() == int.class) {
fields[idx].setAccessible(true);
fields[idx].setInt(obj, 0);
}
}
} catch (final IllegalAccessException ex) {
throw new RuntimeException(ex);
}