List of usage examples for java.util Map.Entry equals
boolean equals(Object o);
From source file:Main.java
public static void main(String args[]) { System.out.println("PATH = " + System.getenv("PATH")); Map<String, String> env = System.getenv(); for (Iterator<Map.Entry<String, String>> it = env.entrySet().iterator(); it.hasNext();) { Map.Entry<String, String> entry = it.next(); System.out.println(entry.equals(entry)); }/*from www . ja va2 s . c om*/ }
From source file:com.mozilla.telemetry.pig.eval.json.ValidateTelemetrySubmission.java
@SuppressWarnings("unchecked") void dumpHistogramValues(String key, Map<String, Object> referenceHistograms) { LOG.info(key);/* w w w .ja v a2 s . c o m*/ for (Map.Entry<String, Object> k : referenceHistograms.entrySet()) { if (!k.equals("values")) { LOG.info(k.getKey() + " " + k.getValue()); } } if (referenceHistograms.containsKey("values")) { Map<String, Object> bucketValues = (Map<String, Object>) referenceHistograms.get("values"); for (Map.Entry<String, Object> bk : bucketValues.entrySet()) { LOG.info(bk.getKey()); } } }
From source file:org.apache.ojb.broker.util.ReferenceMap.java
/** * Returns a set view of this map's entries. * * @return a set view of this map's entries *//*from w w w .j a v a 2 s.c o m*/ public Set entrySet() { if (entrySet != null) return entrySet; entrySet = new AbstractSet() { public int size() { return ReferenceMap.this.size(); } public void clear() { ReferenceMap.this.clear(); } public boolean contains(Object o) { if (o == null) return false; if (!(o instanceof Map.Entry)) return false; Map.Entry e = (Map.Entry) o; Entry e2 = getEntry(e.getKey()); return (e2 != null) && e.equals(e2); } public boolean remove(Object o) { boolean r = contains(o); if (r) { Map.Entry e = (Map.Entry) o; ReferenceMap.this.remove(e.getKey()); } return r; } public Iterator iterator() { return new EntryIterator(); } public Object[] toArray() { return toArray(new Object[0]); } public Object[] toArray(Object[] arr) { ArrayList list = new ArrayList(); Iterator iterator = iterator(); while (iterator.hasNext()) { Entry e = (Entry) iterator.next(); list.add(new DefaultMapEntry(e.getKey(), e.getValue())); } return list.toArray(arr); } }; return entrySet; }
From source file:org.loy.fesf.core.impl.BaseContext.java
/** * <p>/*from w w w . j a v a 2 s. c o m*/ * Remove the specified key-value pair, if it exists, and return * <code>true</code>. If this pair does not exist, return * <code>false</code>. * </p> * * @param entry * Key-value pair to be removed * @return boolean * */ private boolean remove(final Map.Entry entry) { Map.Entry actual = entry(entry.getKey()); if (actual == null) { return (false); } else if (!entry.equals(actual)) { return (false); } else { remove(entry.getKey()); return (true); } }
From source file:org.openhab.binding.ucprelayboard.internal.UCPRelayBoardBinding.java
public void modified(final Map<String, Object> properties) throws InitializationException { if (properties == null) { return;/* w w w . java 2s .c o m*/ } Map<String, SerialDeviceConfig> configs = prepareConfiguration(properties); //create new and modify existing ones for (Map.Entry<String, SerialDeviceConfig> config : configs.entrySet()) { if (serialDevices.containsKey(config.getKey())) { SerialDevice device = serialDevices.get(config.getKey()); if (!config.equals(device.getConfig())) { device.close(); prepareSerialDevice(config.getValue()); } } else { prepareSerialDevice(config.getValue()); } } //close removed ones for (String name : serialDevices.keySet()) { if (!configs.containsKey(name)) { SerialDevice device = serialDevices.get(name); device.close(); serialDevices.remove(name); } } if (serialDevices.size() > 0) { setProperlyConfigured(true); } else { setProperlyConfigured(false); } }