Java Code Examples for java.util.Map#equals()
The following examples show how to use
java.util.Map#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeTemplatesModel.java From netbeans with Apache License 2.0 | 6 votes |
private void fireChanged() { Map<String, CodeTemplateDescription> current = new HashMap<>(); for (int idx = 0; idx < getRowCount(); idx++) { String abbreviation = getAbbreviation(idx); CodeTemplateDescription ctd = new CodeTemplateDescription( abbreviation, getDescription(idx), getText(idx), new ArrayList(getContexts(idx)), getUniqueId(idx), mimeType ); current.put(abbreviation, ctd); } MimePath mimePath = MimePath.parse(mimeType); Map<String, CodeTemplateDescription> saved = CodeTemplateSettingsImpl.get(mimePath).getCodeTemplates(); modified = !current.equals(saved); }
Example 2
Source File: Weather.java From mars-sim with GNU General Public License v3.0 | 6 votes |
/** * Provides the surface temperature or air pressure at a given location from the * temperatureCacheMap. If calling the given location for the first time from * the cache map, call update temperature/air pressure instead * * @return temperature or pressure */ public double getCachedReading(Map<Coordinates, Double> map, Coordinates location) { double result; if (map.containsKey(location)) { result = map.get(location); } else { double cache = 0; // if (value == TEMPERATURE ) if (map.equals(temperatureCacheMap)) cache = calculateTemperature(location); // else if (value == AIR_PRESSURE ) else if (map.equals(airPressureCacheMap)) cache = calculateAirPressure(location, 0); map.put(location, cache); result = cache; } return result; }
Example 3
Source File: RegionVersionVector.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * For test purposes, see if two RVVs have seen the same events * and GC version vectors * @return true if the RVVs are the same. */ public boolean sameAs(RegionVersionVector<T> other) { //Compare the version version vectors Map<T, RegionVersionHolder<T>> myMemberToVersion = getMemberToVersion(); Map<T, RegionVersionHolder<T>> otherMemberToVersion = other.getMemberToVersion(); if (!myMemberToVersion.keySet().equals(otherMemberToVersion.keySet())) { return false; } for (Iterator<T> it = myMemberToVersion.keySet().iterator(); it.hasNext(); ) { T key = it.next(); if (!myMemberToVersion.get(key).sameAs(otherMemberToVersion.get(key))) { return false; } } Map<T, Long> myGCVersion = getMemberToGCVersion(); Map<T, Long> otherGCVersion = other.getMemberToGCVersion(); if(!myGCVersion.equals(otherGCVersion)) { return false; } return true; }
Example 4
Source File: NTypeMerger.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private Map mergeMap(Map a, Map b) throws MergeFailed{ if(a.equals(b)) return a; Map ret = new HashMap(); Set keys = new HashSet(Fp.append(a.keySet(), b.keySet())); for(Object key : keys){ Object ai = a.get(key); Object bi = b.get(key); if(ai != null && bi == null) ret.put(key, ai); else if(ai == null && bi != null) ret.put(key, bi); else if(ai.equals(bi)) ret.put(key, ai); else throw new MergeFailed("a and b are different", ai, bi); } return ret; }
Example 5
Source File: CloudbreakAwait.java From cloudbreak with Apache License 2.0 | 5 votes |
@Override public CloudbreakTestDto await(CloudbreakTestDto entity, Map<String, Status> desiredStatuses, TestContext testContext, RunningParameter runningParameter, Duration pollingInterval, int maxRetry) { try { if (entity == null) { throw new RuntimeException("Cloudbreak key has been provided but no result in resource map!"); } Log.await(LOGGER, String.format("%s for %s", entity.getName(), desiredStatuses)); CloudbreakClient client = testContext.getMicroserviceClient(CloudbreakClient.class, testContext.getWho(runningParameter) .getAccessKey()); String name = entity.getName(); if (desiredStatuses.equals(STACK_DELETED)) { waitForCloudbreakStatuses(new CloudbreakTerminationChecker<>(), client, name, testContext, desiredStatuses, pollingInterval, maxRetry); } else if (desiredStatuses.equals(STACK_FAILED)) { waitForCloudbreakStatuses(new CloudbreakFailedChecker<>(), client, name, testContext, desiredStatuses, pollingInterval, maxRetry); entity.refresh(testContext, client); } else { waitForCloudbreakStatuses(new CloudbreakOperationChecker<>(), client, name, testContext, desiredStatuses, pollingInterval, maxRetry); entity.refresh(testContext, client); } } catch (Exception e) { if (runningParameter.isLogError()) { LOGGER.error("await [{}] is failed for statuses {}: {}, name: {}", entity, desiredStatuses, ResponseUtil.getErrorMessage(e), entity.getName()); Log.await(null, String.format("[%s] is failed for statuses %s: %s, name: %s", entity, desiredStatuses, ResponseUtil.getErrorMessage(e), entity.getName())); } testContext.getExceptionMap().put("await " + entity + " for desired statuses " + desiredStatuses, e); } return entity; }
Example 6
Source File: ButtonIconManager.java From pumpernickel with MIT License | 5 votes |
@Override public void actionPerformed(ActionEvent e) { Map<String, Color> current = getCurrentColors(); display(current); if (current.equals(animationEndColors)) { animationStartColors = null; animationStart = -1; timer.stop(); } }
Example 7
Source File: SettingsGradingSchemaPanel.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Has the page model's grade mapping been changed from the stored one? * * @return */ private boolean isDirty() { // Note that the maps must be HashMaps for the comparison to work properly due to TreeMap.equals() != HashMap.equals(). // get current values final List<GbGradingSchemaEntry> currentValues = SettingsGradingSchemaPanel.this.model.getObject().getGradingSchemaEntries(); final Map<String, Double> currentGradeMapping = new HashMap<>(SettingsHelper.asMap(currentValues)); // get stored values final GradeMappingDefinition storedValues = getGradingSchema(SettingsGradingSchemaPanel.this.currentGradeMappingId); final Map<String, Double> storedGradeMapping = new HashMap<>(storedValues.getGradeMap()); return !currentGradeMapping.equals(storedGradeMapping); }
Example 8
Source File: IsSameEvent.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override protected boolean matchesSafely(String eventAsJson) { if (expectedEvent == null) return false; LOG.trace("Convert the following json string to a map: {}", eventAsJson); Map mapEvent = convertJsonStringToMap(eventAsJson); mapEvent.remove("eventCreatedAt"); Map mapExpectedEvent = getMapWithoutCreatedAt(expectedEvent); LOG.trace("Got the map: {}", mapEvent); LOG.trace("Compare to the expected map: {}", mapExpectedEvent); return mapEvent.equals(mapExpectedEvent); }
Example 9
Source File: IsSameEvent.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override protected boolean matchesSafely(String eventAsJson) { if (expectedEvent == null) return false; LOG.trace("Convert the following json string to a map: {}", eventAsJson); Map mapEvent = convertJsonStringToMap(eventAsJson); mapEvent.remove("eventCreatedAt"); Map mapExpectedEvent = getMapWithoutCreatedAt(expectedEvent); LOG.trace("Got the map: {}", mapEvent); LOG.trace("Compare to the expected map: {}", mapExpectedEvent); return mapEvent.equals(mapExpectedEvent); }
Example 10
Source File: BaseTest.java From fusionauth-jwt with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected void assertJSONEquals(Object object, String jsonFile) throws IOException { Map<String, Object> actual = Mapper.deserialize(Mapper.serialize(object), Map.class); Map<String, Object> expected = Mapper.deserialize(Files.readAllBytes(Paths.get(jsonFile)), Map.class); actual = deepSort(actual); expected = deepSort(expected); if (!actual.equals(expected)) { String actualString = new String(Mapper.prettyPrint(actual)); String expectedString = new String(Mapper.prettyPrint(expected)); throw new AssertionError("The actual JSON doesn't match the expected JSON output. expected [" + expectedString + "] but found [" + actualString + "]"); } }
Example 11
Source File: PatchRequest.java From swaggy-jenkins with MIT License | 5 votes |
@Override public Map<String, String> getHeaders() throws AuthFailureError { Map<String, String> headers = super.getHeaders(); if (headers == null || headers.equals(Collections.emptyMap())) { headers = new HashMap<String, String>(); } if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { headers.putAll(apiHeaders); } if(contentType != null) { headers.put("Content-Type", contentType); } return headers; }
Example 12
Source File: IsSameEvent.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override protected boolean matchesSafely(String eventAsJson) { if (expectedEvent == null) return false; LOG.trace("Convert the following json string to a map: {}", eventAsJson); Map mapEvent = convertJsonStringToMap(eventAsJson); mapEvent.remove("eventCreatedAt"); Map mapExpectedEvent = getMapWithoutCreatedAt(expectedEvent); LOG.trace("Got the map: {}", mapEvent); LOG.trace("Compare to the expected map: {}", mapExpectedEvent); return mapEvent.equals(mapExpectedEvent); }
Example 13
Source File: EvalUtil.java From interface-test with Apache License 2.0 | 5 votes |
/** * Map比较 */ private static boolean evalMap(Map expect, Map actual, String operator) { switch (operator) { case CMP_OP_EQUALS: return expect.equals(actual); case CMP_OP_NOT_EQUALS: return !expect.equals(actual); case CMP_OP_CONTAINS: for (Object expectKey : expect.keySet()) { Object actualValue = actual.get(expectKey); Object expectValue = expect.get(expectKey); if (actualValue == null && expectValue == null) { return true; } else if (actualValue != null && expectValue != null && actualValue.equals(expectValue)) { return true; } } return false; case CMP_OP_NOT_CONTAINS: case CMP_OP_LESS_THAN: case CMP_OP_GREATER_THAN: case CMP_OP_LESS_THAN_EQUALS: case CMP_OP_GREATER_THAN_EQUALS: case CMP_OP_MATCH: case CMP_OP_NOT_MATCH: default: throw new IllegalArgumentException(String.format("【%s】与【%s】不支持进行【%s】比较", expect, actual, operator)); } }
Example 14
Source File: IsSameEvent.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override protected boolean matchesSafely(String eventAsJson) { if (expectedEvent == null) return false; LOG.trace("Convert the following json string to a map: {}", eventAsJson); Map mapEvent = convertJsonStringToMap(eventAsJson); mapEvent.remove("eventCreatedAt"); Map mapExpectedEvent = getMapWithoutCreatedAt(expectedEvent); LOG.trace("Got the map: {}", mapEvent); LOG.trace("Compare to the expected map: {}", mapExpectedEvent); return mapEvent.equals(mapExpectedEvent); }
Example 15
Source File: KeyBindings.java From workspacemechanic with Eclipse Public License 1.0 | 5 votes |
/** * compares first to second, where an empty map substitues for null. */ private static boolean equalMaps( Map<String,String> first, Map<String,String> second) { if (first == null) { first = Collections.emptyMap(); } if (second == null) { second = Collections.emptyMap(); } return second.equals(first); }
Example 16
Source File: PatchRequest.java From swagger-aem with Apache License 2.0 | 5 votes |
@Override public Map<String, String> getHeaders() throws AuthFailureError { Map<String, String> headers = super.getHeaders(); if (headers == null || headers.equals(Collections.emptyMap())) { headers = new HashMap<String, String>(); } if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { headers.putAll(apiHeaders); } if(contentType != null) { headers.put("Content-Type", contentType); } return headers; }
Example 17
Source File: EnvironmentApplicationAttributeUpdater.java From multiapps-controller with Apache License 2.0 | 4 votes |
@Override protected boolean shouldUpdateAttribute(CloudApplication existingApplication, CloudApplication application) { Map<String, String> env = application.getEnv(); Map<String, String> existingEnv = existingApplication.getEnv(); return !existingEnv.equals(env); }
Example 18
Source File: ClusterUpgradeImageFilter.java From cloudbreak with Apache License 2.0 | 4 votes |
private boolean permitLockedComponentsUpgrade(Image currentImage, Image image) { Map<String, String> currentImagePackageVersions = currentImage.getPackageVersions(); Map<String, String> imagePackageVersions = image.getPackageVersions(); return currentImagePackageVersions.equals(imagePackageVersions); }
Example 19
Source File: CollectionPropsTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Test public void testReadWriteCached() throws InterruptedException, IOException { CollectionProperties collectionProps = new CollectionProperties(zkClient()); // NOTE: Using a semaphore to ensure we wait for Watcher to fire before proceeding with // test logic, to prevent triggering SOLR-13678 final Semaphore sawExpectedProps = new Semaphore(0); final AtomicReference<Map<String,String>> expectedProps = new AtomicReference<Map<String,String>>(null); final CollectionPropsWatcher w = new CollectionPropsWatcher() { @Override public boolean onStateChanged(Map<String,String> collectionProperties) { log.info("collection properties changed. Now: {}", collectionProperties); final Map<String,String> expected = expectedProps.get(); if (expected != null && expected.equals(collectionProperties)) { log.info("...new props match expected"); sawExpectedProps.release(); } return false; } }; cluster.getSolrClient().getZkStateReader().registerCollectionPropsWatcher(collectionName, w); collectionProps.setCollectionProperty(collectionName, "property1", "value1"); collectionProps.setCollectionProperty(collectionName, "property2", "value2"); waitForValue("property1", "value1", 5000); waitForValue("property2", "value2", 5000); // HACK: don't let our watcher be removed until we're sure it's "up to date" // with the final prop values expected below... expectedProps.set(new HashMap<>()); collectionProps.setCollectionProperty(collectionName, "property1", "value1"); // no change checkValue("property1", "value1"); collectionProps.setCollectionProperty(collectionName, "property1", null); collectionProps.setCollectionProperty(collectionName, "property2", "newValue"); waitForValue("property1", null, 5000); waitForValue("property2", "newValue", 5000); collectionProps.setCollectionProperty(collectionName, "property2", null); waitForValue("property2", null, 5000); collectionProps.setCollectionProperty(collectionName, "property2", null); // no change checkValue("property2", null); assertTrue("Gave up waitng an excessive amount of time for watcher to see final expected props", sawExpectedProps.tryAcquire(1, 120, TimeUnit.SECONDS)); cluster.getSolrClient().getZkStateReader().removeCollectionPropsWatcher(collectionName, w); collectionProps.setCollectionProperty(collectionName, "property1", "value1"); checkValue("property1", "value1"); //Should be no cache, so the change should take effect immediately }
Example 20
Source File: ResourceManager.java From hawkular-agent with Apache License 2.0 | 4 votes |
@Override public int compare(Resource<L> r1, Resource<L> r2) { // make sure we are looking at the same resource int c = r1.getID().compareTo(r2.getID()); if (c != 0) { return c; } // see if the names changed c = r1.getName().compareTo(r2.getName()); if (c != 0) { return c; } // see if the resource configuration property values are the same Collection<ResourceConfigurationPropertyInstance<L>> rcp1 = r1.getResourceConfigurationProperties(); Collection<ResourceConfigurationPropertyInstance<L>> rcp2 = r2.getResourceConfigurationProperties(); if (rcp1.size() == rcp2.size()) { if (!rcp1.isEmpty()) { Map<ResourceConfigurationPropertyInstance<L>, String> rcp1Map = new HashMap<>(rcp1.size()); for (ResourceConfigurationPropertyInstance<L> rcp1Item : rcp1) { rcp1Map.put(rcp1Item, rcp1Item.getValue()); } Map<ResourceConfigurationPropertyInstance<L>, String> rcp2Map = new HashMap<>(rcp2.size()); for (ResourceConfigurationPropertyInstance<L> rcp2Item : rcp2) { rcp2Map.put(rcp2Item, rcp2Item.getValue()); } if (!rcp1Map.equals(rcp2Map)) { return rcp1Map.hashCode() < rcp2Map.hashCode() ? -1 : 1; } } } else { return rcp1.size() < rcp2.size() ? -1 : 1; } // see if the general properties are the same if (!r1.getProperties().equals(r2.getProperties())) { return r1.getProperties().hashCode() < r2.getProperties().hashCode() ? -1 : 1; } // everything we care about didn't change - consider them the same resource return 0; }