@Override public void processCategoryDefects(Cargo cargo) { if (!cargo.getCondition().isSurveyable()) { return; } // Добавляем недостающие дефекты for (CargoPackage cp : cargo.getCargoPackages()) { for (CargoPackageCalibre calibre : cp.getCalibres()) { for (ArticleCategory category : CargoUtil.getCargoCategoriesForDefects(cargo)) { if (!findDefect(calibre, category)) { CargoCalibreDefect defect = new CargoCalibreDefect(category, calibre); calibre.getCalibreDefects().add(defect); } } } } }
private boolean findDefect(final CargoPackageCalibre calibre, final ArticleCategory category) { return AlgoUtil.find( calibre.getCalibreDefects(), new AlgoUtil.FindPredicate<CargoCalibreDefect>() { @Override public boolean isIt(CargoCalibreDefect defect) { return defect.getArticleCategory().equals(category) && defect.getCalibre().equals(calibre); } }) != null; }