multiple-ifs

How to refactor this code?

Please suggest in refactoring this code. Avoid code duplication, mutiple If's public FormDataDTO getDataForFieldFormCHrzntalField(Field field) { FormDataDTO formDataDTO = new FormDataDTO(); CHrzntalField cHrzntalField = (CHrzntalField) field; for (int j = 0; j < cHrzntalField.getFieldCount(); j++) { Field sField = c...

Effective Use of Java Reflection - is this a hack, or is this standard practice?

Hey, long time listener first time caller, and I'm asking a question related to Java reflection, and how easy it lends itself to apparently ugly coding. The following method attempts to take two similar objects (one object having all of the fields of the other object, and then some) and compare the two of them for equality. It will (al...