List of usage examples for org.apache.commons.collections4 ListUtils subtract
public static <E> List<E> subtract(final List<E> list1, final List<? extends E> list2)
From source file:appsgate.lig.eude.interpreter.langage.nodes.NodeLists.java
/** * Method that compute the combination of the two lists depending on the * operator/*from w w w .j av a 2 s .co m*/ */ private void computeResult() { switch (op) { case UNION: result = ListUtils.sum(leftList.getElements(), rightList.getElements()); break; case INTERSECTION: result = ListUtils.intersection(leftList.getElements(), rightList.getElements()); break; case NOT_IN: result = ListUtils.subtract(leftList.getElements(), rightList.getElements()); break; default: LOGGER.warn("Unknown operator"); } }
From source file:org.kuali.coeus.common.framework.compliance.core.SpecialReviewRuleBase.java
/** * Validates the rules surrounding the protocol number. * /*from ww w. j a v a 2s .c o m*/ * @param specialReview The special review to validate * @param specialReviews The existing special reviews * @param errorString The error string for the type / approval of this special review * @return true if the specialReview is valid, false otherwise */ @SuppressWarnings("unchecked") private boolean validateProtocolNumber(T specialReview, List<T> specialReviews, String errorString) { boolean isValid = true; if (!StringUtils.equals(SpecialReviewApprovalType.NOT_YET_APPLIED, specialReview.getApprovalTypeCode())) { if (StringUtils.isBlank(specialReview.getProtocolNumber())) { isValid = false; reportError(PROTOCOL_NUMBER_FIELD, KeyConstants.ERROR_SPECIAL_REVIEW_REQUIRED_FOR_VALID, PROTOCOL_NUMBER_TITLE, errorString); } else { if (SpecialReviewType.HUMAN_SUBJECTS.equals(specialReview.getSpecialReviewTypeCode())) { Protocol protocol = getProtocolFinderDao() .findCurrentProtocolByNumber(specialReview.getProtocolNumber()); if (protocol == null) { isValid = false; reportError(PROTOCOL_NUMBER_FIELD, KeyConstants.ERROR_SPECIAL_REVIEW_PROTOCOL_NUMBER_INVALID); } else { List<T> existingSpecialReviews = ListUtils.subtract(specialReviews, Collections.singletonList(specialReview)); for (T existingSpecialReview : existingSpecialReviews) { if (StringUtils.equals(specialReview.getProtocolNumber(), existingSpecialReview.getProtocolNumber())) { isValid = false; reportError(PROTOCOL_NUMBER_FIELD, KeyConstants.ERROR_SPECIAL_REVIEW_PROTOCOL_NUMBER_DUPLICATE); } } } } else if (SpecialReviewType.ANIMAL_USAGE.equals(specialReview.getSpecialReviewTypeCode())) { IacucProtocol iacucProtocol = (IacucProtocol) getIacucProtocolFinderDao() .findCurrentProtocolByNumber(specialReview.getProtocolNumber()); if (iacucProtocol == null) { isValid = false; reportError(PROTOCOL_NUMBER_FIELD, KeyConstants.ERROR_SPECIAL_REVIEW_PROTOCOL_NUMBER_INVALID); } else { List<T> existingSpecialReviews = ListUtils.subtract(specialReviews, Collections.singletonList(specialReview)); for (T existingSpecialReview : existingSpecialReviews) { if (StringUtils.equals(specialReview.getProtocolNumber(), existingSpecialReview.getProtocolNumber())) { isValid = false; reportError(PROTOCOL_NUMBER_FIELD, KeyConstants.ERROR_SPECIAL_REVIEW_PROTOCOL_NUMBER_DUPLICATE); } } } } } } return isValid; }