/** * Returns true if this Fqn is equals or the child of parentFqn. Example usage: * * <pre> * Fqn<String> f1 = Fqn.fromString("/a/b"); * Fqn<String> f2 = Fqn.fromString("/a/b/c"); * assertTrue(f1.isChildOrEquals(f2)); * assertTrue(f1.isChildOrEquals(f1)); * assertFalse(f2.isChildOrEquals(f1)); * </pre> * * @param parentFqn candidate parent to test against * @return true if this Fqn is equals or the child of parentFqn. */ public boolean isChildOrEquals(Fqn parentFqn) { Object[] parentEl = parentFqn.elements; if (parentEl.length > elements.length) { return false; } for (int i = parentEl.length - 1; i >= 0; i--) { if (!Util.safeEquals(parentEl[i], elements[i])) return false; } return true; }
private boolean replace(AdvancedCache<?, ?> cache, K key, V oldValue, V newValue) { startAtomic(); try { AtomicMap<K, V> data = getDataInternal(cache); V old = data.get(key); if (Util.safeEquals(oldValue, old)) { data.put(key, newValue); return true; } return false; } finally { endAtomic(); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; EventImpl<?, ?> event = (EventImpl<?, ?>) o; if (originLocal != event.originLocal) return false; if (pre != event.pre) return false; if (transactionSuccessful != event.transactionSuccessful) return false; if (cache != null ? !cache.equals(event.cache) : event.cache != null) return false; if (key != null ? !key.equals(event.key) : event.key != null) return false; if (transaction != null ? !transaction.equals(event.transaction) : event.transaction != null) return false; if (type != event.type) return false; if (value != null ? !value.equals(event.value) : event.value != null) return false; if (!Util.safeEquals(consistentHashAtStart, event.consistentHashAtStart)) return false; if (!Util.safeEquals(consistentHashAtEnd, event.consistentHashAtEnd)) return false; if (!Util.safeEquals(membersAtStart, event.membersAtStart)) return false; if (!Util.safeEquals(membersAtEnd, event.membersAtEnd)) return false; if (newViewId != event.newViewId) return false; return true; }
@Override public boolean replace(K key, V oldValue, V newValue) { startAtomic(); try { AtomicMap<K, V> data = getDataInternal(); V old = data.get(key); if (Util.safeEquals(oldValue, old)) { data.put(key, newValue); return true; } return false; } finally { endAtomic(); } }
/** Returns true if obj is a Fqn with the same elements. */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Fqn)) { return false; } Fqn other = (Fqn) obj; if (elements.length != other.elements.length) return false; for (int i = elements.length - 1; i >= 0; i--) { if (!Util.safeEquals(elements[i], other.elements[i])) return false; } return true; }