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

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

Introduction

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

Prototype

public static boolean isSubCollection(final Collection a, final Collection b) 

Source Link

Document

Returns true iff a is a sub-collection of b, that is, iff the cardinality of e in a is less than or equal to the cardinality of e in b, for each element e in a.

Usage

From source file:com.googlecode.androidcartridge.metafacades.authentication.AuthenticationControllerFacadeLogicImpl.java

@Override
protected boolean handleIsAccountDataFullySpecified() {
    String[] requiredProps = new String[] { "hostName", "port", "webappRoot", "ssl" };
    Collection<String> allNames = new ArrayList<String>();
    Collection<AttributeFacade> properties = getAllProperties();
    for (AttributeFacade property : properties) {
        allNames.add(property.getName());
    }// www  . ja va2  s  .com

    return CollectionUtils.isSubCollection(allNames, Arrays.asList(requiredProps));
}

From source file:com.intellij.struts2.dom.struts.StrutsHighlightingSpringTest.java

public void testStrutsSpringCompletionVariants() throws Throwable {
    @NonNls//w  w w  .  j  a v  a  2 s.co m
    final String strutsXml = "struts-completionvariants-spring.xml";
    createStrutsFileSet(strutsXml);

    createSpringFileSet(SPRING_XML);

    // TODO <alias> does not appear here, see com.intellij.spring.impl.SpringModelImpl#myOwnBeans
    final List<String> variants = myFixture.getCompletionVariants(strutsXml);

    Assert.assertTrue(CollectionUtils.isSubCollection(
            Arrays.asList("MyClass", "bean1", "bean2", "springInterceptor", "springResultType"), variants));
}

From source file:RepositoryEncCompatibilityTest.java

private static void checkRestoreTo(final String passwordData, final String passwordMeta, List<String> argList)
        throws Exception {

    CipherProvider dataCipherProvider = new CipherProvider();
    dataCipherProvider.setPassword(passwordData);
    CipherProvider metaCipherProvider = new CipherProvider();
    metaCipherProvider.setPassword(passwordMeta);

    String repoPathStr = REPO_TST;
    Repository repository = new Repository(repoPathStr, dataCipherProvider, metaCipherProvider);

    RestoreService restore = new RestoreService("encCmpRepo_2013-12-17_08-45-57", repository, argList,
            RESTORE_TST);//w  w  w.j a  v  a  2  s .  co m
    restore.run();

    // check new dir content
    List<String> contentRestore = getContentDir(RESTORE_TST, true);
    printContent(contentRestore);
    Assert.assertTrue(contentRestore.size() == 6);
    Assert.assertTrue(CollectionUtils.isSubCollection(getContentRestorePatern(), contentRestore));
}

From source file:com.shigengyu.hyperion.core.WorkflowStateSet.java

public boolean isSubSetOf(WorkflowStateSet workflowStateSet) {
    return CollectionUtils.isSubCollection(workflowStates, workflowStateSet.workflowStates);
}

From source file:BackupRestoreTest.java

private static void checkRestoreTo(final String passwordData, final String passwordMeta,
        final Collection<String> repoPatern, List<String> argList) throws Exception {
    CipherProvider dataCipherProvider = new CipherProvider();
    dataCipherProvider.setPassword(passwordData);
    CipherProvider metaCipherProvider = new CipherProvider();
    metaCipherProvider.setPassword(passwordMeta);

    String repoPathStr = REPO_TST;
    Repository repository = new Repository(repoPathStr, dataCipherProvider, metaCipherProvider);

    VOConfig cfg = new VOConfig(REPO_TST, ID_BCK_TST, getExcl("*.excl"), getExcl("*Excl"), argList);

    BackupService backup = new BackupService(cfg, repository);
    final String bck = backup.run();

    // check repo content
    List<String> contentRepo = getContentDir(REPO_TST + File.separator + "data", false);
    printContent(contentRepo);/*from   w  ww.  j  a  v  a 2s.co  m*/
    checkCollectionIn(repoPatern, contentRepo);

    RestoreService restore = new RestoreService(bck, repository, argList, RESTORE_TST);
    restore.run();

    // check new dir content
    List<String> contentRestore = getContentDir(RESTORE_TST, false);
    // TODO Lebeda - do check with date - on source tst files must be dat prepared on setup test
    printContent(contentRestore);
    Assert.assertEquals(16, contentRestore.size());
    Assert.assertTrue(0 == CollectionUtils.countMatches(contentRestore, new Predicate() {
        @Override
        public boolean evaluate(final Object object) {
            String s = (String) object;
            return StringUtils.contains(s, "excl");
        }
    }));
    Assert.assertTrue(CollectionUtils.isSubCollection(getContentRestorePatern(), contentRestore));
}

From source file:com.shigengyu.hyperion.core.WorkflowStateSet.java

public boolean isSuperSetOf(WorkflowStateSet workflowStateSet) {
    return CollectionUtils.isSubCollection(workflowStateSet.workflowStates, workflowStates);
}

From source file:info.magnolia.cms.util.WebXmlUtil.java

/**
 * Returns:/* w  ww  . j  a v  a2 s . c om*/
 * +1 if all mandatory dispatchers are present and no additional unsupported dispatcher is present, or this filter class isn't registered.
 * 0  if all mandatory dispatchers are present but additional unsupported dispatchers are present.
 * -1  if not all mandatory dispatchers are present.
 */
public int checkFilterDispatchersConfiguration(String filterClass, List mandatoryDispatchers,
        List optionalDispatchers) {
    final Element filterEl = getFilterElement(filterClass);
    if (filterEl != null) {
        final String filterName = filterEl.getTextNormalize();
        final String filterMappingXPathExpr = "/webxml:web-app/webxml:filter-mapping[webxml:filter-name='"
                + filterName + "']/webxml:dispatcher";
        final List dispatchersEl = getElementsFromXPath(filterMappingXPathExpr);
        final List registeredDispatchers = new ArrayList();
        final Iterator it = dispatchersEl.iterator();
        while (it.hasNext()) {
            final Element dispatcherEl = (Element) it.next();
            registeredDispatchers.add(dispatcherEl.getTextNormalize());
        }
        registeredDispatchers.removeAll(optionalDispatchers);
        if (CollectionUtils.isEqualCollection(mandatoryDispatchers, registeredDispatchers)) {
            return 1;
        } else if (CollectionUtils.isSubCollection(mandatoryDispatchers, registeredDispatchers)) {
            return 0;
        } else {
            return -1;
        }

    }
    return 1;
}

From source file:org.kuali.student.enrollment.class2.courseoffering.service.impl.CourseOfferingServiceMapImpl.java

@Override
public List<RegistrationGroupInfo> getRegistrationGroupsWithActivityOfferings(List<String> activityOfferingIds,
        ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
        OperationFailedException, PermissionDeniedException {

    List<RegistrationGroupInfo> regGroupList = new ArrayList<RegistrationGroupInfo>();

    for (RegistrationGroupInfo rg : this.registrationGroupMap.values()) {
        if (CollectionUtils.isSubCollection(activityOfferingIds, rg.getActivityOfferingIds())) {
            regGroupList.add(rg);/*from  www.  j  a  v  a 2s . c  om*/
        }
    }

    return regGroupList;

}

From source file:org.pentaho.platform.web.servlet.AdhocWebService.java

private static boolean isSetConsistent(Set<Integer> unitsSet) {
    return unitsSet.isEmpty() || CollectionUtils.isSubCollection(unitsSet, PERCENT_SET);
}