本文整理了Java中java.lang.Object.equals()
方法的一些代码示例,展示了Object.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Object.equals()
方法的具体详情如下:
包路径:java.lang.Object
类名称:Object
方法名:equals
暂无
代码示例来源:origin: ReactiveX/RxJava
/**
* Compares two potentially null objects with each other using Object.equals.
* @param o1 the first object
* @param o2 the second object
* @return the comparison result
*/
public static boolean equals(Object o1, Object o2) { // NOPMD
return o1 == o2 || (o1 != null && o1.equals(o2));
}
代码示例来源:origin: google/guava
@Override
public boolean equals(Object other) {
if (other instanceof InternerFunction) {
InternerFunction<?> that = (InternerFunction<?>) other;
return interner.equals(that.interner);
}
return false;
}
}
代码示例来源:origin: square/retrofit
private static int indexOf(Object[] array, Object toFind) {
for (int i = 0; i < array.length; i++) {
if (toFind.equals(array[i])) return i;
}
throw new NoSuchElementException();
}
代码示例来源:origin: square/okhttp
@Override public boolean equals(@Nullable Object other) {
if (!(other instanceof Handshake)) return false;
Handshake that = (Handshake) other;
return tlsVersion.equals(that.tlsVersion)
&& cipherSuite.equals(that.cipherSuite)
&& peerCertificates.equals(that.peerCertificates)
&& localCertificates.equals(that.localCertificates);
}
代码示例来源:origin: google/guava
@Override
public boolean equals(@Nullable Object object) {
if (object instanceof Present) {
Present<?> other = (Present<?>) object;
return reference.equals(other.reference);
}
return false;
}
代码示例来源:origin: square/okhttp
boolean equalsNonHost(Address that) {
return this.dns.equals(that.dns)
&& this.proxyAuthenticator.equals(that.proxyAuthenticator)
&& this.protocols.equals(that.protocols)
&& this.connectionSpecs.equals(that.connectionSpecs)
&& this.proxySelector.equals(that.proxySelector)
&& Objects.equals(this.proxy, that.proxy)
&& Objects.equals(this.sslSocketFactory, that.sslSocketFactory)
&& Objects.equals(this.hostnameVerifier, that.hostnameVerifier)
&& Objects.equals(this.certificatePinner, that.certificatePinner)
&& this.url().port() == that.url().port();
}
代码示例来源:origin: google/guava
@Override
public boolean equals(Object obj) {
if (obj instanceof DummyHandler) {
DummyHandler that = (DummyHandler) obj;
return identity().equals(that.identity());
} else {
return false;
}
}
代码示例来源:origin: google/guava
static <K, V> ImmutableSortedMap<K, V> emptyMap(Comparator<? super K> comparator) {
if (Ordering.natural().equals(comparator)) {
return of();
} else {
return new ImmutableSortedMap<>(
ImmutableSortedSet.emptySet(comparator), ImmutableList.<V>of());
}
}
代码示例来源:origin: google/guava
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof HasAnInterface) {
HasAnInterface that = (HasAnInterface) obj;
return i.equals(that.i);
} else {
return false;
}
}
代码示例来源:origin: google/guava
@Override
public boolean equals(@Nullable Object obj) {
// In general getClass().isInstance() is bad for equals.
// But here we fully control the subclasses to ensure symmetry.
if (getClass().isInstance(obj)) {
Wrapper that = (Wrapper) obj;
return wrapped.equals(that.wrapped);
}
return false;
}
代码示例来源:origin: google/guava
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
public void testSetValueWithNullValuesPresent() {
for (Entry<K, V> entry : getMap().entrySet()) {
if (entry.getKey().equals(k0())) {
assertEquals("entry.setValue() should return the old value", v0(), entry.setValue(null));
break;
}
}
expectReplacement(entry(k0(), (V) null));
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(Object t) {
if (t.equals(1)) {
HalfSerializer.onNext(a[0], 2, wip, error);
}
ts.onNext(t);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(Object t) {
if (t.equals(1)) {
HalfSerializer.onNext(a[0], 2, wip, error);
}
to.onNext(t);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(Object t) {
if (t.equals(1)) {
HalfSerializer.onComplete(a[0], wip, error);
}
ts.onNext(t);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(Object t) {
if (t.equals(1)) {
HalfSerializer.onComplete(a[0], wip, error);
}
to.onNext(t);
}
代码示例来源:origin: google/guava
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testSetValue() {
for (Entry<K, V> entry : getMap().entrySet()) {
if (entry.getKey().equals(k0())) {
assertEquals("entry.setValue() should return the old value", v0(), entry.setValue(v3()));
break;
}
}
expectReplacement(entry(k0(), v3()));
}
代码示例来源:origin: google/guava
@GwtIncompatible // ImmutableSortedSet.indexOf
// TODO(cpovirk): consider manual binary search under GWT to preserve O(log N) lookup
@Override
public int indexOf(@Nullable Object target) {
int index = delegateCollection().indexOf(target);
// TODO(kevinb): reconsider if it's really worth making feeble attempts at
// sanity for inconsistent comparators.
// The equals() check is needed when the comparator isn't compatible with
// equals().
return (index >= 0 && get(index).equals(target)) ? index : -1;
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(Object t) {
if (t.equals(1)) {
HalfSerializer.onError(a[0], new TestException(), wip, error);
}
ts.onNext(t);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(Object t) {
if (t.equals(1)) {
HalfSerializer.onError(a[0], new TestException(), wip, error);
}
to.onNext(t);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void errorNotificationCompare() {
TestException ex = new TestException();
Object n1 = NotificationLite.error(ex);
assertEquals(ex.hashCode(), n1.hashCode());
assertFalse(n1.equals(NotificationLite.complete()));
}
}
内容来源于网络,如有侵权,请联系作者删除!