Example usage for org.apache.commons.collections ListUtils isEqualList

List of usage examples for org.apache.commons.collections ListUtils isEqualList

Introduction

In this page you can find the example usage for org.apache.commons.collections ListUtils isEqualList.

Prototype

public static boolean isEqualList(final Collection list1, final Collection list2) 

Source Link

Document

Tests two lists for value-equality as per the equality contract in java.util.List#equals(java.lang.Object) .

Usage

From source file:com.hs.mail.imap.message.search.OrKey.java

public boolean equals(Object obj) {
    if (!(obj instanceof OrKey))
        return false;
    return ListUtils.isEqualList(keys, ((OrKey) obj).getSearchKeys());
}

From source file:com.hs.mail.imap.message.search.AndKey.java

public boolean equals(Object obj) {
    if (!(obj instanceof AndKey))
        return false;
    return ListUtils.isEqualList(keys, ((AndKey) obj).getSearchKeys());
}

From source file:ml.shifu.shifu.container.obj.ComboModelTrain.java

@Override
public boolean equals(Object obj) {
    if (obj == null || !(obj instanceof ComboModelTrain)) {
        return false;
    }//from  www .j av  a2  s  .  c o m

    ComboModelTrain other = (ComboModelTrain) obj;
    if (other == this) {
        return true;
    }

    return ListUtils.isEqualList(subTrainConfList, other.getSubTrainConfList());
}

From source file:com.vmware.photon.controller.apife.db.dao.TenantDaoTest.java

@Test
public void testCreateAndDelete() {
    List<SecurityGroupEntity> securityGroups = new ArrayList<>();
    securityGroups.add(new SecurityGroupEntity("adminGroup1", true));
    securityGroups.add(new SecurityGroupEntity("adminGroup2", true));
    securityGroups.add(new SecurityGroupEntity("adminGroup3", false));

    TenantEntity tenant = new TenantEntity();
    tenant.setName(tenantName);/*from  w  w w . j  ava  2  s.c  om*/
    tenant.setSecurityGroups(securityGroups);
    tenantDao.create(tenant);

    String id = tenant.getId();

    sessionFactory.getCurrentSession().flush();
    sessionFactory.getCurrentSession().clear();

    // assert that the object was created and can be found
    Optional<TenantEntity> found = tenantDao.findById(id);
    assertThat(found.isPresent(), is(true));

    // validate some key fields
    assertThat(found.get().getId(), isA(String.class));
    assertThat(found.get().getName(), isA(String.class));

    assertThat(found.get().getId(), comparesEqualTo(id));
    assertThat(found.get().getName(), comparesEqualTo(tenantName));
    assertThat(found.get().getKind(), equalTo(TenantEntity.KIND));
    assertThat(ListUtils.isEqualList(found.get().getSecurityGroups(), securityGroups), is(true));

    tenantDao.delete(found.get());
    found = tenantDao.findById(id);
    assertThat(found.isPresent(), is(false));
}

From source file:com.vmware.photon.controller.apife.db.dao.ProjectDaoTest.java

@Test
public void testCreateAndDelete() {
    List<SecurityGroupEntity> securityGroups = new ArrayList<>();
    securityGroups.add(new SecurityGroupEntity("adminGroup1", true));
    securityGroups.add(new SecurityGroupEntity("adminGroup2", true));
    securityGroups.add(new SecurityGroupEntity("adminGroup3", false));

    ProjectEntity project = new ProjectEntity();
    project.setTenantId(tenant.getId());
    project.setName("TestProject");
    project.setSecurityGroups(securityGroups);
    projectDao.create(project);/*from   ww w .  j a  v a  2s.  co m*/

    String id = project.getId();

    sessionFactory.getCurrentSession().flush();
    sessionFactory.getCurrentSession().clear();

    // assert that the project was found and that it contains
    // the right tenant object
    Optional<ProjectEntity> found = projectDao.findById(id);
    assertThat(found.isPresent(), is(true));
    assertThat(found.get().getTenantId(), is(tenant.getId()));
    assertThat(ListUtils.isEqualList(found.get().getSecurityGroups(), securityGroups), is(true));

    projectDao.delete(found.get());
    found = projectDao.findById(id);
    assertThat(found.isPresent(), is(false));
}

From source file:fr.mcc.ginco.audit.commands.SynonymsCommandBuilder.java

/**
 * Builds the list of command lines for synonyms changes between two
 * revisions/* w w  w. jav  a 2s.  c o m*/
 * @param previousConcepts
 * @param currentConcepts
 * @param oldRevision
 * @param currentRevision
 * @param lang
 * @return
 */
public List<CommandLine> buildSynonyms(List<ThesaurusConcept> previousConcepts,
        List<ThesaurusConcept> currentConcepts, Number oldRevision, Number currentRevision, String lang) {
    List<CommandLine> termsOperations = new ArrayList<CommandLine>();

    Map<String, List<String>> previousSynonyms = mistralStructuresBuilder
            .buildSynonymsStructure(previousConcepts, oldRevision, lang);
    Map<String, List<String>> currentSynonyms = mistralStructuresBuilder.buildSynonymsStructure(currentConcepts,
            currentRevision, lang);

    // Check for existence/non existence of previous synonyms
    for (String previousSynonym : previousSynonyms.keySet()) {
        if (currentSynonyms.containsKey(previousSynonym)) {
            if (!ListUtils.isEqualList(previousSynonyms.get(previousSynonym),
                    currentSynonyms.get(previousSynonym))) {
                // Change of synonyms list
                for (String termValue : previousSynonyms.get(previousSynonym)) {
                    if (!currentSynonyms.get(previousSynonym).contains(termValue)) {
                        // Synonym has been removed from list
                        CommandLine synonymRemovedLine = new CommandLine();
                        synonymRemovedLine
                                .setValue(CommandLine.SEPARATE + StringEscapeUtils.unescapeXml(termValue));
                        termsOperations.add(synonymRemovedLine);
                    }
                }
                for (String termValue : currentSynonyms.get(previousSynonym)) {
                    if (!previousSynonyms.get(previousSynonym).contains(termValue)) {
                        // Synonym has been added to list
                        CommandLine synonymAddedLine = new CommandLine();
                        synonymAddedLine.setValue(StringEscapeUtils.unescapeXml(previousSynonym)
                                + CommandLine.SYNONYM + StringEscapeUtils.unescapeXml(termValue));
                        termsOperations.add(synonymAddedLine);
                    }
                }
            }
        } else {
            // Synonyms suppression
            for (String prevSynonymValue : previousSynonyms.get(previousSynonym)) {
                CommandLine synonymRemovedLine = new CommandLine();
                synonymRemovedLine
                        .setValue(CommandLine.SEPARATE + StringEscapeUtils.unescapeXml(prevSynonymValue));
                termsOperations.add(synonymRemovedLine);
            }
        }
    }

    // Check for addition of synonyms relations
    for (String currentSynonym : currentSynonyms.keySet()) {
        if (!previousSynonyms.containsKey(currentSynonym) && currentSynonyms.get(currentSynonym).size() > 0) {
            CommandLine synonymsAddedLine = new CommandLine();
            String lineValue = StringEscapeUtils.unescapeXml(currentSynonym);
            for (String synonym : currentSynonyms.get(currentSynonym)) {
                lineValue += CommandLine.SYNONYM + StringEscapeUtils.unescapeXml(synonym);
            }
            synonymsAddedLine.setValue(lineValue);
            termsOperations.add(synonymsAddedLine);
        }
    }

    return termsOperations;
}

From source file:fr.mcc.ginco.audit.commands.HierarchyCommandBuilder.java

/**
 * Builds the list of command lines for hierarchy changes between two
 * revisions//from   ww  w  .  j ava  2  s.  com
 *
 * @param previousConcepts
 * @param currentConcepts
 * @param oldRevision
 * @param currentRevision
 * @param lang
 * @return
 */
public List<CommandLine> buildHierarchyChanges(List<ThesaurusConcept> previousConcepts,
        List<ThesaurusConcept> currentConcepts, Number oldRevision, Number currentRevision, String lang) {
    List<CommandLine> termsOperations = new ArrayList<CommandLine>();

    Map<String, List<String>> previousHierarchies = mistralStructuresBuilder
            .buildHierarchyStructure(previousConcepts, oldRevision, lang);
    Map<String, List<String>> currentHierarchies = mistralStructuresBuilder
            .buildHierarchyStructure(currentConcepts, currentRevision, lang);
    for (String previousParentConceptId : previousHierarchies.keySet()) {
        if (currentHierarchies.containsKey(previousParentConceptId)) {
            // Concept still exists
            if (!ListUtils.isEqualList(previousHierarchies.get(previousParentConceptId),
                    currentHierarchies.get(previousParentConceptId))) {
                // but hierarchy has changed
                for (String oldChild : previousHierarchies.get(previousParentConceptId)) {
                    if (!currentHierarchies.get(previousParentConceptId).contains(oldChild)) {
                        // child removed
                        CommandLine childRemovedLine = new CommandLine();
                        childRemovedLine.setValue(CommandLine.HIERARCHY_REMOVED
                                + StringEscapeUtils.unescapeXml(oldChild) + CommandLine.HIERARCHY
                                + StringEscapeUtils.unescapeXml(previousParentConceptId));
                        termsOperations.add(childRemovedLine);
                    }
                }
                for (String newChild : currentHierarchies.get(previousParentConceptId)) {
                    if (!previousHierarchies.get(previousParentConceptId).contains(newChild)) {
                        // child added
                        CommandLine childAddedLine = new CommandLine();
                        childAddedLine.setValue(StringEscapeUtils.unescapeXml(newChild) + CommandLine.HIERARCHY
                                + StringEscapeUtils.unescapeXml(previousParentConceptId));
                        termsOperations.add(childAddedLine);
                    }
                }
            }
        } else {
            // Concept does not exist anymore, remove all old hierarchies
            for (String oldChild : previousHierarchies.get(previousParentConceptId)) {
                CommandLine childRemovedLine = new CommandLine();
                childRemovedLine.setValue(CommandLine.HIERARCHY_REMOVED
                        + StringEscapeUtils.unescapeXml(oldChild) + CommandLine.HIERARCHY
                        + StringEscapeUtils.unescapeXml(previousParentConceptId));
                termsOperations.add(childRemovedLine);
            }
        }
    }

    for (String currentParentConceptId : currentHierarchies.keySet()) {
        if (!previousHierarchies.containsKey(currentParentConceptId)) {
            // Add all new hierarchies
            for (String child : currentHierarchies.get(currentParentConceptId)) {
                CommandLine hierarchyAddedLine = new CommandLine();
                hierarchyAddedLine.setValue(StringEscapeUtils.unescapeXml(child) + CommandLine.HIERARCHY
                        + StringEscapeUtils.unescapeXml(currentParentConceptId));
                termsOperations.add(hierarchyAddedLine);
            }
        }

    }
    return termsOperations;

}

From source file:gov.nih.nci.caarray.services.data.DataRetrievalServiceBean.java

private boolean allDesignElementListsAreConsistent(List<DataSet> dataSets) {
    final DesignElementList firstList = dataSets.get(0).getDesignElementList();
    for (int i = 1; i < dataSets.size(); i++) {
        final DesignElementList nextList = dataSets.get(i).getDesignElementList();
        if (!ListUtils.isEqualList(firstList.getDesignElements(), nextList.getDesignElements())) {
            return false;
        }/* w w  w.j  a v a  2s  .  c  o m*/
    }
    return true;
}

From source file:com.ebay.cloud.cms.dal.persistence.flatten.impl.IndexBuildCommand.java

private Set<String> getUpdateIndex(Map<String, DBObject> exsitingIndexMap, MetaClass meta) {
    Collection<IndexInfo> collection = meta.getIndexes();
    Set<String> updateIndexes = new HashSet<String>();
    for (IndexInfo info : collection) {
        if (exsitingIndexMap.containsKey(info.getIndexName())) {
            boolean diff = false;
            DBObject dbo = exsitingIndexMap.get(info.getIndexName());
            // key check : cast as BasicDBObject, so that we could go through the insert order
            // FIXME :: don't support compare key order. If we support key order specify, then we need to add this comparison 
            BasicDBObject keyObjs = (BasicDBObject) dbo.get("key");
            DBObject keyObject = buildIndexKeyObject(meta, info, onMainBranch);
            diff = !ListUtils.isEqualList(keyObjs.keySet(), keyObject.keySet());

            if (!diff) {
                // option check when keys check passed
                List<IndexOptionEnum> exsitingOption = new ArrayList<IndexInfo.IndexOptionEnum>();
                for (IndexOptionEnum ioe : IndexOptionEnum.values()) {
                    if (dbo.containsField(ioe.name().toLowerCase())
                            && Boolean.parseBoolean(dbo.get(ioe.name().toLowerCase()).toString())) {
                        exsitingOption.add(ioe);
                    }//from w  w w .j a  v  a  2s  .  c  o m
                }
                if (!ListUtils.subtract(exsitingOption, info.getIndexOptions()).isEmpty()
                        || !ListUtils.subtract(info.getIndexOptions(), exsitingOption).isEmpty()) {
                    diff = true;
                }
            }
            if (diff) {
                updateIndexes.add(info.getIndexName());
            }
        }
    }
    return updateIndexes;
}

From source file:com.xpn.xwiki.plugin.watchlist.WatchListStore.java

/**
 * Create or update the watchlist class properties.
 * //from w  ww  .j  av  a2s  .  c o  m
 * @param watchListClass document in which the class must be created
 * @param context the XWiki context
 * @return true if the class properties have been created or modified
 * @throws XWikiException when retrieving of watchlist jobs in the wiki fails
 */
private boolean initWatchListClassProperties(XWikiDocument watchListClass, XWikiContext context)
        throws XWikiException {
    boolean needsUpdate = false;
    BaseClass bclass = watchListClass.getxWikiClass();
    bclass.setName(WATCHLIST_CLASS);

    needsUpdate |= bclass.addStaticListField(WATCHLIST_CLASS_INTERVAL_PROP, "Email notifications interval", "");

    // Check that the interval property contains all the available jobs
    StaticListClass intervalClass = (StaticListClass) bclass.get(WATCHLIST_CLASS_INTERVAL_PROP);
    List<String> intervalValues = intervalClass.getList(context);

    // Look for missing or outdated jobs in the interval list
    Collections.sort(jobDocumentNames);
    if (!ListUtils.isEqualList(intervalValues, jobDocumentNames)) {
        needsUpdate = true;
        intervalClass.setValues(StringUtils.join(jobDocumentNames, PIPE_SEP));
    }

    // Create storage properties
    needsUpdate |= bclass.addTextAreaField(WATCHLIST_CLASS_WIKIS_PROP, "Wiki list", 80, 5);
    needsUpdate |= bclass.addTextAreaField(WATCHLIST_CLASS_SPACES_PROP, "Space list", 80, 5);
    needsUpdate |= bclass.addTextAreaField(WATCHLIST_CLASS_DOCUMENTS_PROP, "Document list", 80, 5);
    needsUpdate |= bclass.addTextAreaField(WATCHLIST_CLASS_USERS_PROP, "User list", 80, 5);

    needsUpdate |= bclass.addStaticListField(WATCHLIST_CLASS_AUTOMATICWATCH, "Automatic watching",
            "default|" + StringUtils.join(AutomaticWatchMode.values(), PIPE_SEP));

    return needsUpdate;
}