private MedicationUnitVoCollection getUnits(DynamicGridRowCollection rows) { if (rows == null) return null; MedicationUnitVoCollection result = new MedicationUnitVoCollection(); for ( int i = 0 ; i < rows.size() ; i++) { if (rows.get(i).getValue() instanceof MedicationUnitVo) { MedicationUnitVo x = (MedicationUnitVo) rows.get(i).getValue(); if (x.getDoseUnitIsNotNull()) result.add(x); } } if (result.size()==0) return null; return result; }