for (Vigilant vigilant : vigilants) { if (vigilant.getVigilantGroupsCount() == 1) { try { vigilant.delete(); } catch (DomainException e) { unableToRemove.add(vigilant); } } else { group.removeVigilants(vigilant); } }
Set<VigilantGroup> groups = vigilantsToRemove.keySet(); for (VigilantGroup group : groups) { List<Vigilant> vigilants = vigilantsToRemove.get(group); for (Vigilant vigilant : vigilants) { if (vigilant.getVigilantGroupsCount() == 1) { try { vigilant.delete(); } catch (DomainException e) { unableToRemove.add(vigilant); } } else { group.removeVigilants(vigilant); } } }
    public List<Vigilant> run(List<Vigilant> vigilants, VigilantGroup group) throws ExcepcaoPersistencia {        List<Vigilant> unableToRemove = new ArrayList<Vigilant>();        for (Vigilant vigilant : vigilants) {            if (vigilant.getVigilantGroupsCount() == 1) {                try {                    vigilant.delete();                } catch (DomainException e) {                    unableToRemove.add(vigilant);                }            } else {                group.removeVigilants(vigilant);            }        }        return unableToRemove;    }