List of usage examples for java.util Map equals
boolean equals(Object o);
From source file:com.enonic.cms.core.security.user.UserEntity.java
/** * @return true if changes where made./*from ww w . j ava 2s . c o m*/ */ public boolean overwriteUserFields(final UserFields userFields) { final Map<String, String> newFieldMap = new UserFieldTransformer().toStoreableMap(userFields); removeFieldsWithNullValueWhenFieldDoesNotExist(newFieldMap); final Map<String, String> oldFieldMap = Maps.newHashMap(this.fieldMap); this.fieldMap.putAll(newFieldMap); final UserField photoField = userFields.getField(UserFieldType.PHOTO); this.photo = photoField != null ? (byte[]) photoField.getValue() : null; // invalidate this.userFields = null; return !oldFieldMap.equals(fieldMap); }
From source file:com.linkedin.pinot.integration.tests.StarTreeClusterIntegrationTest.java
/** * Wait for External View to be in sync with Ideal State. * @return/* w w w. ja va 2 s. c om*/ */ private boolean waitForExternalViewUpdate() { final ZKHelixAdmin helixAdmin = new ZKHelixAdmin(ZkStarter.DEFAULT_ZK_STR); ClusterStateVerifier.Verifier customVerifier = new ClusterStateVerifier.Verifier() { @Override public boolean verify() { String clusterName = getHelixClusterName(); List<String> resourcesInCluster = helixAdmin.getResourcesInCluster(clusterName); LOGGER.info("Waiting for external view to update for resources: {} startTime: {}", resourcesInCluster, new Timestamp(System.currentTimeMillis())); for (String resourceName : resourcesInCluster) { IdealState idealState = helixAdmin.getResourceIdealState(clusterName, resourceName); ExternalView externalView = helixAdmin.getResourceExternalView(clusterName, resourceName); LOGGER.info("HERE for {},\n IS:{} \n EV:{}", resourceName, idealState, externalView); if (idealState == null || externalView == null) { return false; } Set<String> partitionSet = idealState.getPartitionSet(); for (String partition : partitionSet) { Map<String, String> instanceStateMapIS = idealState.getInstanceStateMap(partition); Map<String, String> instanceStateMapEV = externalView.getStateMap(partition); if (instanceStateMapIS == null || instanceStateMapEV == null) { return false; } if (!instanceStateMapIS.equals(instanceStateMapEV)) { return false; } } LOGGER.info("External View updated successfully for {},\n IS:{} \n EV:{}", resourceName, idealState, externalView); } LOGGER.info("External View updated successfully for {}", resourcesInCluster); return true; } }; return ClusterStateVerifier.verifyByPolling(customVerifier, TIMEOUT_IN_MILLISECONDS); }
From source file:org.candlepin.model.ConsumerCurator.java
private boolean factsChanged(Map<String, String> updatedFacts, Map<String, String> existingFacts) { return !existingFacts.equals(updatedFacts); }
From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java
@Test(dataProvider = "guardedMap") public void equals_whenEmpty(Map<Object, Object> map) { Map<Object, Object> empty = ImmutableMap.of(); assertThat(map.equals(empty), is(true)); assertThat(empty.equals(map), is(true)); }
From source file:com.enonic.cms.core.security.user.UserEntity.java
/** * Replaces user fiels with given and returns true if it changed from previous user fields. *///from w w w .ja va2 s . com public boolean setUserFields(final UserFields userFields) { final Map<String, String> newFieldMap = new UserFieldTransformer().toStoreableMap(userFields); removeFieldsWithNullValueWhenFieldDoesNotExist(newFieldMap); final Map<String, String> oldFieldMap = Maps.newHashMap(this.fieldMap); this.fieldMap.clear(); fieldMap.putAll(newFieldMap); final UserField photoField = userFields.getField(UserFieldType.PHOTO); this.photo = photoField != null ? (byte[]) photoField.getValue() : null; // invalidate this.userFields = null; return !oldFieldMap.equals(fieldMap); }
From source file:org.ow2.proactive.scheduler.common.job.factories.JobComparator.java
private boolean isEqualMap(Map<?, ?> m1, Map<?, ?> m2) { if ((m1 == null) && (m2 == null)) return true; if ((m1 == null) || (m2 == null)) return false; return m1.equals(m2); }
From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java
@Test(dataProvider = "warmedMap") public void equals_whenPopulated(Map<Integer, Integer> map) { Map<Integer, Integer> expected = ImmutableMap.copyOf(newWarmedMap()); assertThat(map.equals(expected), is(true)); assertThat(expected.equals(map), is(true)); }
From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java
private void checkEqualsAndHashCodeNotEqual(Map<Integer, Integer> first, Map<Integer, Integer> second, String errorMsg) {/*from w ww.jav a 2 s . c o m*/ Map<Integer, Integer> map = newGuarded(); Map<Integer, Integer> other = newHashMap(); map.putAll(first); other.putAll(second); assertThat(errorMsg, map.equals(other), is(false)); assertThat(errorMsg, other.equals(map), is(false)); assertThat(errorMsg, map.hashCode(), is(not(equalTo(other.hashCode())))); }
From source file:org.deri.iris.queryrewriting.PositionDependenciesTest.java
@Test public void testPositionDependenciesInverse() throws Exception { //// www . j a va2 s. c o m // Theory: // // [R1] t(X,Y) -> t(Y,X). // final IPredicate t = Factory.BASIC.createPredicate("t", 2); final ILiteral txy = Factory.BASIC.createLiteral(true, t, tupleXY); final ILiteral tyx = Factory.BASIC.createLiteral(true, t, tupleYX); // Input structure final List<ILiteral> h1 = new LinkedList<ILiteral>(); final List<ILiteral> b1 = new LinkedList<ILiteral>(); b1.add(txy); h1.add(tyx); final IRule r1 = Factory.BASIC.createRule(h1, b1); final List<IRule> in = ImmutableList.of(r1); // // Comparison Structure: // // t[1] -> t[1] {<>, <R1,R1>} // t[2] -> t[2] {<>, <R1,R1>} // // t[1] -> t[2] {<R2>} // t[2] -> t[1] {<R2>} // final Map<Pair<IPosition, IPosition>, Set<List<IRule>>> cmp = new HashMap<Pair<IPosition, IPosition>, Set<List<IRule>>>(); final IPosition t1 = new Position(t.getPredicateSymbol(), 1); final IPosition t2 = new Position(t.getPredicateSymbol(), 2); final List<IRule> lEmpty = ImmutableList.of(); final List<IRule> lr1r1 = ImmutableList.of(r1, r1); final Set<List<IRule>> st1t1 = Sets.newLinkedHashSet(); st1t1.add(lEmpty); st1t1.add(lr1r1); final Set<List<IRule>> st2t2 = Sets.newLinkedHashSet(); st2t2.add(lEmpty); st2t2.add(lr1r1); // t[1] -> t[1] {<>, <R1,R1>} cmp.put(Pair.of(t1, t1), st1t1); // t[2] -> t[2] {<>, <R1,R1>} cmp.put(Pair.of(t2, t2), st2t2); // t[1] -> t[2] {<R1>} // t[2] -> t[1] {<R1>} final List<IRule> lr1 = ImmutableList.of(r1); final Set<List<IRule>> slr1 = Sets.newLinkedHashSet(); slr1.add(lr1); cmp.put(Pair.of(t1, t2), slr1); cmp.put(Pair.of(t2, t1), slr1); final Map<Pair<IPosition, IPosition>, Set<List<IRule>>> depGraph = DepGraphUtils .computePositionDependencyGraph(in); LOGGER.debug(depGraph.toString()); System.out.println("Actual:" + depGraph.toString()); System.out.println("Expected:" + cmp.toString()); assertEquals(true, depGraph.equals(cmp)); }
From source file:org.grails.datastore.mapping.model.config.GormMappingConfigurationStrategy.java
private Map getAssociationMap(ClassPropertyFetcher cpf, String relationshipType) { Map relationshipMap = cpf.getStaticPropertyValue(relationshipType, Map.class); if (relationshipMap == null) { relationshipMap = new HashMap(); } else {//from w ww . j a v a 2 s. c o m relationshipMap = new HashMap(relationshipMap); } Class theClass = cpf.getJavaClass(); while (theClass != Object.class) { theClass = theClass.getSuperclass(); ClassPropertyFetcher propertyFetcher = ClassPropertyFetcher.forClass(theClass); Map superRelationshipMap = propertyFetcher.getStaticPropertyValue(relationshipType, Map.class); if (superRelationshipMap != null && !superRelationshipMap.equals(relationshipMap)) { relationshipMap.putAll(superRelationshipMap); } } return relationshipMap; }