Example usage for org.apache.commons.collections CollectionUtils disjunction

List of usage examples for org.apache.commons.collections CollectionUtils disjunction

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils disjunction.

Prototype

public static Collection disjunction(final Collection a, final Collection b) 

Source Link

Document

Returns a Collection containing the exclusive disjunction (symmetric difference) of the given Collection s.

Usage

From source file:org.wicketstuff.datatable_autocomplete.trie.BasicPrefixTrieTestCase.java

public void testAnyDoubleZeroMatch() {

    List<String> wordList = trie.getWordList("00");

    @SuppressWarnings("unchecked")
    Collection<String> disjunction = CollectionUtils.disjunction(wordList, doubleZeroWordList);

    for (String string : disjunction) {
        System.out.println("extra = " + string);
    }/*from  w ww.  ja  v a  2 s.  c o  m*/

    assertEquals(doubleZeroWordList.size(), wordList.size());

}

From source file:org.wicketstuff.datatable_autocomplete.trie.BasicPrefixTrieTestCase.java

public void testAnyOneMatch() {

    List<String> wordList = trie.getWordList("1");

    @SuppressWarnings("unchecked")
    Collection<String> disjunction = CollectionUtils.disjunction(wordList, oneWordList);

    for (String string : disjunction) {
        System.out.println("extra = " + string);
    }// w  w  w  .  jav  a 2s. c  om

    assertEquals(oneWordList.size(), wordList.size());

}

From source file:org.wicketstuff.datatable_autocomplete.trie.LargeTrieTestCase.java

public void testTrieStructure() {

    List<String> nextCharacterList = new LinkedList<String>();
    nextCharacterList.addAll(trie.getNextNodeCharacterSet());

    Collections.sort(nextCharacterList);

    for (String c : nextCharacterList) {

        List<Method> wordList = trie.getWordList(c);

        List<Method> indexedList = builder.getListForFirstCharacter(c);

        Collections.sort(wordList, methodComparator);
        Collections.sort(indexedList, methodComparator);

        for (int i = 0; i < wordList.size(); i++) {

            Method found = wordList.get(i);
            Method indexed = wordList.get(i);

            String foundString = found.toString();
            String indexedString = indexed.toString();

            if (!foundString.equals(indexedString)) {
                System.out.println("found = " + found.toString());
                System.out.println("as indexed = " + indexed.toString());
            }//from  w  w w. j  a  v  a  2s. com

            assertEquals(found.toString(), indexed.toString());

        }

        for (int i = wordList.size(); i < indexedList.size(); i++) {

            System.out.println("found = NONE");
            System.out.println("as indexed = " + indexedList.get(i).toString());

        }

        // get the list of elements that are not in the union of the two lists
        @SuppressWarnings("unchecked")
        Collection<Method> disjunctionList = CollectionUtils.disjunction(wordList, indexedList);

        for (Method method : disjunctionList) {

            System.out.println("missing = " + method.toString());
        }

        assertEquals(wordList.size(), indexedList.size());

    }

}

From source file:org.wicketstuff.datatable_autocomplete.tst.LargeTrieTestCase.java

public void testTrieStructure() {

    List<String> nextCharacterList = new LinkedList<String>();

    nextCharacterList.addAll(trie.getNextNodeCharacterSet());

    Collections.sort(nextCharacterList);

    for (String c : nextCharacterList) {

        List<Method> wordList = trie.getWordList(c, -1);

        List<Method> indexedList = builder.getListForFirstCharacter(c);

        Collections.sort(wordList, methodComparator);
        Collections.sort(indexedList, methodComparator);

        for (int i = 0; i < wordList.size(); i++) {

            Method found = wordList.get(i);
            Method indexed = wordList.get(i);

            String foundString = found.toString();
            String indexedString = indexed.toString();

            if (!foundString.equals(indexedString)) {
                System.out.println("found = " + found.toString());
                System.out.println("as indexed = " + indexed.toString());
            }// w  w  w . j  a va 2 s . c  o m

            assertEquals(found.toString(), indexed.toString());

        }

        for (int i = wordList.size(); i < indexedList.size(); i++) {

            System.out.println("found = NONE");
            System.out.println("as indexed = " + indexedList.get(i).toString());

        }

        // get the list of elements that are not in the union of the two lists
        @SuppressWarnings("unchecked")
        Collection<Method> disjunctionList = CollectionUtils.disjunction(wordList, indexedList);

        for (Method method : disjunctionList) {

            System.out.println("missing = " + method.toString());
        }

        assertEquals(wordList.size(), indexedList.size());

    }

}

From source file:services.plugins.subversion.subv1.SubversionPluginRunner.java

/**
 * Check if the update of the system role may have an impact on the
 * subversion LDAP configuration.//from w  w w  .  j  av  a 2s .  com
 * 
 * @param eventMessage
 *            the event message
 */
private void checkImpactOfSystemLevelRoleUpdate(EventMessage eventMessage) {
    // A role was updated, check if this role was associated with
    // the permission SCM_DEVELOPER_PERMISSION
    // or SCM_ADMIN
    Long changedRole = eventMessage.getInternalId();
    List<String> previousListOfPermissions = ((SystemLevelRoleTypeEventMessage.PayLoad) eventMessage
            .getPayload()).getPreviousPermissionNames();

    // Check if the permission is new or removed
    List<String> currentPermissions = new ArrayList<String>();
    SystemLevelRoleType roleType = SystemLevelRoleType.getActiveRoleFromId(changedRole);
    if (roleType.systemPermissions != null) {
        for (SystemPermission systemPermission : roleType.systemPermissions) {
            currentPermissions.add(systemPermission.name);
        }
    }

    Collection<?> changedPermissions = CollectionUtils.disjunction(previousListOfPermissions,
            currentPermissions);
    if (changedPermissions.contains(IMafConstants.SCM_DEVELOPER_PERMISSION)
            || changedPermissions.contains(IMafConstants.SCM_ADMIN_PERMISSION)) {
        List<Principal> principals = Principal.getPrincipalsWithSystemLevelRoleId(changedRole);

        // Part of removed permissions
        Collection<?> removedPermissions = CollectionUtils.subtract(previousListOfPermissions,
                currentPermissions);
        if (removedPermissions.contains(IMafConstants.SCM_DEVELOPER_PERMISSION)) {
            removeUsersFromLdapGroupFollowingRoleUpdate(principals, getDeveloperLdapGroup());
        }
        if (removedPermissions.contains(IMafConstants.SCM_ADMIN_PERMISSION)) {
            removeUsersFromLdapGroupFollowingRoleUpdate(principals, getDeliveryManagerLdapGroup());
        }

        // Part of added permission
        Collection<?> addedPermissions = CollectionUtils.subtract(currentPermissions,
                previousListOfPermissions);
        if (addedPermissions.contains(IMafConstants.SCM_DEVELOPER_PERMISSION)) {
            addUsersToLdapGroupFollowingRoleUpdate(principals, getDeveloperLdapGroup());
        }
        if (addedPermissions.contains(IMafConstants.SCM_ADMIN_PERMISSION)) {
            addUsersToLdapGroupFollowingRoleUpdate(principals, getDeliveryManagerLdapGroup());
        }
    }
}

From source file:uk.ac.cam.quebec.core.WorkAllocator.java

private Collection<Thread> getRunningTasks() {
    Collection<Thread> disjunction = CollectionUtils.disjunction(ThreadPool, ThreadQueue);
    return disjunction;
}