public boolean supports(Class aClass) {
return EquipmentInspection.class.isAssignableFrom(aClass);
}
public void validate(Object o, Errors errors) {
EquipmentInspection equipmentInspection = (EquipmentInspection) o;
if (equipmentInspection.getType().trim().equals("") || equipmentInspection.getMark().trim().equals("")) {
if (equipmentInspection.getType().trim().equals("")) {
errors.rejectValue("type", "equipmentInspection.type.error");
}
if (equipmentInspection.getMark().trim().equals("")) {
errors.rejectValue("mark", "equipmentInspection.mark.error");
}
if (equipmentInspection.getFactoryNumber().trim().equals("")) {
errors.rejectValue("factoryNumber", "equipmentInspection.number.error");
}
} else {
if (equipmentInspectionManager.exist(equipmentInspection) && equipmentInspection.getEquipmentId() == null) {
errors.rejectValue("equipmentId", "equipmentInspection.error");
}
}
}