List of usage examples for org.apache.commons.collections CollectionUtils isEqualCollection
public static boolean isEqualCollection(final Collection a, final Collection b)
From source file:net.firejack.platform.core.config.meta.construct.RelationshipConfigElement.java
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof RelationshipConfigElement)) return false; RelationshipConfigElement that = (RelationshipConfigElement) o; boolean propEmpty = fields == null || fields.isEmpty(); boolean thatPropEmpty = that.fields == null || that.fields.isEmpty(); if ((propEmpty && !thatPropEmpty) || (!propEmpty && thatPropEmpty)) { return false; } else if (!propEmpty && !thatPropEmpty && !CollectionUtils.isEqualCollection(fields, that.fields)) { return false; }/* www. j av a 2s.c o m*/ return name.equals(that.name) && onDeleteOptions == that.onDeleteOptions && onUpdateOptions == that.onUpdateOptions && !((required != null && required) ^ (that.required != null && that.required)) && source.equals(that.source) && type == that.type && ((type != RelationshipType.TREE && target.equals(that.target)) || type == RelationshipType.TREE); }
From source file:com.baidu.rigel.biplatform.ma.model.meta.DimTableMetaDefine.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }/*from w w w . j a va 2s . c om*/ if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } DimTableMetaDefine other = (DimTableMetaDefine) obj; if (columns == null) { if (other.columns != null) { return false; } } else if (!CollectionUtils.isEqualCollection(columns, other.columns)) { return false; } if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } if (reference == null) { if (other.reference != null) { return false; } } else if (!reference.equals(other.reference)) { return false; } return true; }
From source file:com.shigengyu.hyperion.core.WorkflowStateSet.java
public boolean isSameWith(WorkflowStateSet workflowStateSet) { return CollectionUtils.isEqualCollection(workflowStates, workflowStateSet.workflowStates); }
From source file:de.hybris.platform.cms2.servicelayer.services.admin.impl.DefaultCMSAdminRestrictionServiceIntegrationTest.java
/** * Test method for// ww w. j av a 2s. c o m * {@link de.hybris.platform.cms2.servicelayer.services.admin.impl.DefaultCMSAdminRestrictionService#getCategories(de.hybris.platform.cms2.model.restrictions.CMSCategoryRestrictionModel, de.hybris.platform.cms2.model.preview.PreviewDataModel)} * . */ @Test public void shouldGetCategoriesForRestriction() { // given final List<CategoryModel> categories = new ArrayList<CategoryModel>(); categories.add(categoryService.getCategory("testCategory0")); categories.add(categoryService.getCategory("testCategory1")); categories.add(categoryService.getCategory("testCategory2")); final CMSCategoryRestrictionModel categoryRestriction = modelService .create(CMSCategoryRestrictionModel.class); categoryRestriction.setUid("FooBar"); categoryRestriction.setCategories(categories); modelService.save(categoryRestriction); // when final List<CategoryModel> restrictedCategories = cmsAdminRestrictionService .getCategories(categoryRestriction, previewContext); // then assertThat(restrictedCategories).hasSize(3); assertThat(CollectionUtils.isEqualCollection(restrictedCategories, categories)).isTrue(); final CatalogVersionAssertion testCategory0 = new CatalogVersionAssertion(restrictedCategories.get(0)); final CatalogVersionAssertion testCategory1 = new CatalogVersionAssertion(restrictedCategories.get(1)); final CatalogVersionAssertion testCategory2 = new CatalogVersionAssertion(restrictedCategories.get(2)); assertThat(testCategory0).hasSameCatalogVersion(getCatalogVersion()); assertThat(testCategory1).hasSameCatalogVersion(getCatalogVersion()); assertThat(testCategory2).hasSameCatalogVersion(getCatalogVersion()); }
From source file:com.cloudera.nav.plugin.model.relations.RelationTest.java
@Test public void testLogicalPhysical() { HdfsEntity logical = new HdfsEntity(); String idOfLogical = "logicalEntityId"; String sourceIdOfLogical = "sourceIdOfLogicalEntity"; logical.setIdentity(idOfLogical);//from ww w. j a v a 2 s .com logical.setSourceId(sourceIdOfLogical); HdfsEntity physical1 = new HdfsEntity(); String idOfPhysical = "physicalEntityId"; String sourceIdOfPhysical = "sourceIdOfPhysicalEntity"; physical1.setIdentity(idOfPhysical); physical1.setSourceId(sourceIdOfPhysical); HdfsEntity physical2 = new HdfsEntity(); String idOfPhysical2 = "physical2EntityId"; physical2.setIdentity(idOfPhysical2); physical2.setSourceId(sourceIdOfPhysical); LogicalPhysicalRelation rel = LogicalPhysicalRelation.builder().logical(logical) .physical(ImmutableList.<Entity>of(physical1, physical2)).namespace("test") .idGenerator(new RelationIdGenerator()).build(); assertEquals(rel.getLogicalId(), idOfLogical); assertTrue(CollectionUtils.isEqualCollection(Sets.newHashSet(rel.getPhysicalIds()), Sets.newHashSet(idOfPhysical, idOfPhysical2))); assertEquals(rel.getSourceTypeOfLogical(), logical.getSourceType()); assertEquals(rel.getSourceTypeOfPhysical(), physical2.getSourceType()); assertEquals(rel.getType(), RelationType.LOGICAL_PHYSICAL); assertEquals(rel.getNamespace(), "test"); }
From source file:net.sf.jtmt.clustering.KMeansClusterer.java
/** * Cluster.//from w w w.j a v a2 s .co m * * @param collection the collection * @return the list */ public List<Cluster> cluster(DocumentCollection collection) { int numDocs = collection.size(); int numClusters = 0; if (initialClusterAssignments == null) { // compute initial cluster assignments IdGenerator idGenerator = new IdGenerator(numDocs); numClusters = (int) Math.floor(Math.sqrt(numDocs)); initialClusterAssignments = new String[numClusters]; for (int i = 0; i < numClusters; i++) { int docId = idGenerator.getNextId(); initialClusterAssignments[i] = collection.getDocumentNameAt(docId); } } else { numClusters = initialClusterAssignments.length; } // build initial clusters List<Cluster> clusters = new ArrayList<Cluster>(); for (int i = 0; i < numClusters; i++) { Cluster cluster = new Cluster("C" + i); cluster.addDocument(initialClusterAssignments[i], collection.getDocument(initialClusterAssignments[i])); clusters.add(cluster); } log.debug("..Initial clusters:" + clusters.toString()); List<Cluster> prevClusters = new ArrayList<Cluster>(); // Repeat until termination conditions are satisfied for (;;) { // For every cluster i, (re-)compute the centroid based on the // current member documents. (We have moved 2.2 above 2.1 because // this needs to be done before every iteration). RealMatrix[] centroids = new RealMatrix[numClusters]; for (int i = 0; i < numClusters; i++) { RealMatrix centroid = clusters.get(i).getCentroid(); centroids[i] = centroid; } // For every document d, find the cluster i whose centroid is // most similar, assign d to cluster i. (If a document is // equally similar from all centroids, then just dump it into // cluster 0). for (int i = 0; i < numDocs; i++) { int bestCluster = 0; double maxSimilarity = Double.MIN_VALUE; RealMatrix document = collection.getDocumentAt(i); String docName = collection.getDocumentNameAt(i); for (int j = 0; j < numClusters; j++) { double similarity = clusters.get(j).getSimilarity(document); if (similarity > maxSimilarity) { bestCluster = j; maxSimilarity = similarity; } } for (Cluster cluster : clusters) { if (cluster.getDocument(docName) != null) { cluster.removeDocument(docName); } } clusters.get(bestCluster).addDocument(docName, document); } log.debug("..Intermediate clusters: " + clusters.toString()); // Check for termination -- minimal or no change to the assignment // of documents to clusters. if (CollectionUtils.isEqualCollection(clusters, prevClusters)) { break; } prevClusters.clear(); prevClusters.addAll(clusters); } // Return list of clusters log.debug("..Final clusters: " + clusters.toString()); return clusters; }
From source file:de.hybris.platform.order.ZoneDeliveryModeServiceTest.java
/** * Tries to search for the delivery mode with code: * <ul>/*w w w . ja va 2 s. c o m*/ * <li>successful with "courier",</li> * <li>caught UnknownIdentifierException with "No_Such_DeliveryMode",</li> * <li>found all delivery modes, whose size is 3.</li> * </ul> */ @Test public void testGetDeliveryMode() { String deliveryModeCode = "courier"; DeliveryModeModel deliveryMode = zoneDeliveryModeService.getDeliveryModeForCode(deliveryModeCode); assertNotNull(deliveryMode); assertEquals(deliveryModeCode, deliveryMode.getCode()); deliveryModeCode = "No_Such_DeliveryMode"; try { deliveryMode = zoneDeliveryModeService.getDeliveryModeForCode(deliveryModeCode); fail("the delivery mode code [" + deliveryMode + "] should NOT be found."); } catch (final UnknownIdentifierException ue) { //expected } final String[] expectedDeliveryModes = { "collect", "courier", "dhl", "fedex", "post", "postService", "ups" }; final Collection<DeliveryModeModel> deliveryModes = zoneDeliveryModeService.getAllDeliveryModes(); assertEquals(expectedDeliveryModes.length, deliveryModes.size()); final List<String> _expectedDeliveryModes = Arrays.asList(expectedDeliveryModes); final List<String> _deliveryModes = new ArrayList<String>(); for (final DeliveryModeModel mode : deliveryModes) { _deliveryModes.add(mode.getCode()); } final boolean same = CollectionUtils.isEqualCollection(_expectedDeliveryModes, _deliveryModes); assertTrue(same); }
From source file:hudson.plugins.depgraph_view.model.graph.CycleFinderTest.java
@Test public void test1CycleEdges() throws IOException { createProjects();//from w w w.ja va2 s. c o m addDependency(project1, project2); addDependency(project2, project3); addDependency(project3, project1); j.getInstance().rebuildDependencyGraph(); DependencyGraph graph = generateGraph(project2); assertGraphContainsProjects(graph, project1, project2, project3); System.out.println(CycleFinder.getCycleEdges(graph)); System.out.println(graph.getEdges()); assertTrue(CollectionUtils.isEqualCollection(CycleFinder.getCycleEdges(graph), graph.getEdges())); }
From source file:com.baidu.rigel.biplatform.ma.model.meta.StarModel.java
/** * {@inheritDoc}// www . jav a2 s . c om */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } StarModel other = (StarModel) obj; if (cubeId == null) { if (other.cubeId != null) { return false; } } else if (!cubeId.equals(other.cubeId)) { return false; } if (dimTables == null) { if (other.dimTables != null) { return false; } } else if (!CollectionUtils.isEqualCollection(dimTables, other.dimTables)) { return false; } if (dsId == null) { if (other.dsId != null) { return false; } } else if (!dsId.equals(other.dsId)) { return false; } if (factTable == null) { if (other.factTable != null) { return false; } } else if (!factTable.equals(other.factTable)) { return false; } if (schemaId == null) { if (other.schemaId != null) { return false; } } else if (!schemaId.equals(other.schemaId)) { return false; } return true; }
From source file:com.cloudera.nav.sdk.model.relations.RelationTest.java
@Test public void testLogicalPhysical() { HdfsEntity logical = new HdfsEntity(); String idOfLogical = "logicalEntityId"; String sourceIdOfLogical = "sourceIdOfLogicalEntity"; logical.setIdentity(idOfLogical);//from ww w .j a v a2s . co m logical.setSourceId(sourceIdOfLogical); logical.setEntityType(EntityType.DIRECTORY); HdfsEntity physical1 = new HdfsEntity(); String idOfPhysical = "physicalEntityId"; String sourceIdOfPhysical = "sourceIdOfPhysicalEntity"; physical1.setIdentity(idOfPhysical); physical1.setSourceId(sourceIdOfPhysical); physical1.setEntityType(EntityType.DIRECTORY); HdfsEntity physical2 = new HdfsEntity(); String idOfPhysical2 = "physical2EntityId"; physical2.setIdentity(idOfPhysical2); physical2.setSourceId(sourceIdOfPhysical); physical2.setEntityType(EntityType.DIRECTORY); LogicalPhysicalRelation rel = LogicalPhysicalRelation.builder().logical(logical) .physical(ImmutableList.<Entity>of(physical1, physical2)).namespace("test") .idGenerator(new RelationIdGenerator()).build(); assertEquals(rel.getLogicalId(), idOfLogical); assertTrue(CollectionUtils.isEqualCollection(Sets.newHashSet(rel.getPhysicalIds()), Sets.newHashSet(idOfPhysical, idOfPhysical2))); assertEquals(rel.getSourceTypeOfLogical(), logical.getSourceType()); assertEquals(rel.getSourceTypeOfPhysical(), physical2.getSourceType()); assertEquals(rel.getType(), RelationType.LOGICAL_PHYSICAL); assertEquals(rel.getNamespace(), "test"); }