return DefectType.class.isAssignableFrom(candidate);
}
public void validate(Object obj, Errors errors) {
DefectType defectType = (DefectType) obj;
//checking defect materials
List materialList = defectType.getMaterials();
for (int i = 0; i < materialList.size(); i++) {
Material material = (Material) materialList.get(i);
if (material.getMaterialId().equals(new Long(-1))) {
errors.rejectValue("materials[" + i + "]", "defectType.noMaterial");
}
}
//checking defect varities
List varityList = defectType.getVarities();
for (int i = 0; i < varityList.size(); i++) {
DefectVarity defectVarity = (DefectVarity) varityList.get(i);
if (defectVarity.getVarityId().equals(new Long(-1))) {
errors.rejectValue("varities[" + i + "]", "defectType.noVarity");
}
}
//checking defect varities
List constructionTypeList = defectType.getConstructionTypes();
for (int i = 0; i < constructionTypeList.size(); i++) {
ConstructionType constructionType = (ConstructionType) constructionTypeList.get(i);
if (constructionType.getConstructionTypeId().equals(new Long(-1))) {
errors.rejectValue("constructionTypes[" + i + "]", "defectType.noConstructionType");
}