/** * 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"; }
@Override public String toString() { return emitter.toString(); } }
/** * 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)); }
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(); }
/** * 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; }
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(); }
@Override public int hashCode() { Object o = value; return o != null ? o.hashCode() : 0; }
@Override public String toString() { return String.format("%s{%s}", getClass().getSimpleName(), super.toString()); } }
@Override public String toString() { return val.toString(); }
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(); }
@Override public int hashCode() { return e.hashCode(); }
@Override public String toString() { return String.format("%s{%s}", getClass().getSimpleName(), super.toString()); } }
@Override public String toString() { return '[' + element.toString() + ']'; } }
@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); }
@Override public String toString() { return String.format("%s{%s}", getClass().getSimpleName(), super.toString()); } }