/** * <code>put</code> method that may be used to check for updates in a thread-safe manner. * * @return <code>true</code> if the put resulted in a change in value, <code>false</code> otherwise. */ public boolean putAndCheckUpdate(K key, V value) { AbstractMap.SimpleImmutableEntry<K, V> kvp = new AbstractMap.SimpleImmutableEntry<K, V>(key, value); AbstractMap.SimpleImmutableEntry<K, V> priorKVP = cache.asMap().put(key, kvp); return priorKVP != null && (! priorKVP.equals(kvp)); }
/** * <code>put</code> method that may be used to check for updates in a thread-safe manner. * * @return <code>true</code> if the put resulted in a change in value, <code>false</code> otherwise. */ public boolean putAndCheckUpdate(K key, V value) { AbstractMap.SimpleImmutableEntry<K, V> kvp = new AbstractMap.SimpleImmutableEntry<K, V>(key, value); AbstractMap.SimpleImmutableEntry<K, V> priorKVP = cache.asMap().put(key, kvp); return priorKVP != null && (! priorKVP.equals(kvp)); }
@Override public boolean equals(Object obj){ if (obj == null || this.getClass() != obj.getClass()) return false; if (obj == this) return true; Pair p = (Pair) obj; return data.equals(p.data); }