java.lang.Object类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(259)

本文整理了Java中java.lang.Object类的一些代码示例,展示了Object类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Object类的具体详情如下:
包路径:java.lang.Object
类名称:Object

Object介绍

暂无

代码示例

代码示例来源:origin: ReactiveX/RxJava

/**
 * Appends the class name to a non-null value.
 * @param o the object
 * @return the string representation
 */
public static String valueAndClass(Object o) {
  if (o != null) {
    return o + " (class: " + o.getClass().getSimpleName() + ")";
  }
  return "null";
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public String toString() {
    return emitter.toString();
  }
}

代码示例来源: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: ReactiveX/RxJava

@Test
  public void validateSubscription() {
    BooleanSubscription bs1 = new BooleanSubscription();

    assertFalse(EndConsumerHelper.validate(SubscriptionHelper.CANCELLED, bs1, getClass()));

    assertTrue(bs1.isCancelled());

    assertTrue(errors.toString(), errors.isEmpty());
  }
}

代码示例来源: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

private static void assertEqualTypeVariable(TypeVariable<?> expected, TypeVariable<?> actual) {
 assertEquals(expected.toString(), actual.toString());
 assertEquals(expected.getName(), actual.getName());
 assertEquals(expected.getGenericDeclaration(), actual.getGenericDeclaration());
 if (!Types.NativeTypeVariableEquals.NATIVE_TYPE_VARIABLE_ONLY) {
  assertEquals(actual.toString(), expected.hashCode(), actual.hashCode());
 }
 assertThat(actual.getBounds())
   .asList()
   .containsExactlyElementsIn(asList(expected.getBounds()))
   .inOrder();
}

代码示例来源:origin: ReactiveX/RxJava

/**
 * Returns the hashCode of a non-null object or zero for a null object.
 * @param o the object to get the hashCode for.
 * @return the hashCode
 */
public static int hashCode(Object o) {
  return o != null ? o.hashCode() : 0;
}

代码示例来源: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()));
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void validateDisposable() {
  Disposable d1 = Disposables.empty();
  assertFalse(EndConsumerHelper.validate(DisposableHelper.DISPOSED, d1, getClass()));
  assertTrue(d1.isDisposed());
  assertTrue(errors.toString(), errors.isEmpty());
}

代码示例来源:origin: google/guava

private static void assertEqualWildcardType(WildcardType expected, WildcardType actual) {
 assertEquals(expected.toString(), actual.toString());
 assertEquals(actual.toString(), expected.hashCode(), actual.hashCode());
 assertThat(actual.getLowerBounds())
   .asList()
   .containsExactlyElementsIn(asList(expected.getLowerBounds()))
   .inOrder();
 assertThat(actual.getUpperBounds())
   .asList()
   .containsExactlyElementsIn(asList(expected.getUpperBounds()))
   .inOrder();
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public int hashCode() {
  Object o = value;
  return o != null ? o.hashCode() : 0;
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public String toString() {
    return String.format("%s{%s}", getClass().getSimpleName(), super.toString());
  }
}

代码示例来源:origin: iluwatar/java-design-patterns

@Override
public String toString() {
 return val.toString();
}

代码示例来源: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: ReactiveX/RxJava

@Override
public int hashCode() {
  return e.hashCode();
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public String toString() {
    return String.format("%s{%s}", getClass().getSimpleName(), super.toString());
  }
}

代码示例来源:origin: google/guava

@Override
 public String toString() {
  return '[' + element.toString() + ']';
 }
}

代码示例来源: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 int hashCode() {
  return SequentialFunnel.class.hashCode() ^ elementFunnel.hashCode();
 }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public String toString() {
    return String.format("%s{%s}", getClass().getSimpleName(), super.toString());
  }
}

相关文章