@Test public void testHashCode() { String className = "clazz"; String method = "method"; String fileName = "file.java"; int lineNumber = 42; Frame frame = new Frame(className, method, fileName, lineNumber); assertThat("Hash codes generated on the same objects should be equal!", frame.hashCode(), equalTo(frame.hashCode())); assertThat("Hash codes generated on equal objects should be equal!", frame.hashCode(), equalTo(new Frame(className, method, fileName, lineNumber).hashCode())); assertThat("Hash codes generated on non equal objects should be different!", frame.hashCode(), not(new Frame("other", method, fileName, lineNumber).hashCode())); assertThat("Hash codes generated on non equal objects should be different!", frame.hashCode(), not(new Frame(className, "other", fileName, lineNumber).hashCode())); assertThat("Hash codes generated on non equal objects should be different!", frame.hashCode(), not(new Frame(className, method, "other", lineNumber).hashCode())); assertThat("Hash codes generated on non equal objects should be different!", frame.hashCode(), not(new Frame(className, method, fileName, 24).hashCode())); }
@Override public int hashCode() { return Objects.hash(className, methodName, fileName, lineNumber); }
Frame { @Override public int hashCode() { return Objects.hash(className, methodName, fileName, lineNumber); } }
Frame { @Override public int hashCode() { return Objects.hash(className, methodName, fileName, lineNumber); } Frame(String className, String methodName);  Frame(String className, String methodName, String fileName, int lineNumber); }
Frame { @Override public int hashCode() { return Objects.hash(className, methodName, fileName, lineNumber); } Frame(String className, String methodName);  Frame(String className, String methodName, String fileName, int lineNumber); String getClassName(); void setClassName(String className); String getMethodName(); void setMethodName(String methodName); String getFileName(); int getLineNumber(); void setLocation(String fileName, int lineNumber); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); boolean isNative(); boolean isUnknown(); }
Frame { @Override public int hashCode() { return Objects.hash(className, methodName, fileName, lineNumber); } Frame(String className, String methodName);  Frame(String className, String methodName, String fileName, int lineNumber); String getClassName(); void setClassName(String className); String getMethodName(); void setMethodName(String methodName); String getFileName(); int getLineNumber(); void setLocation(String fileName, int lineNumber); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); boolean isNative(); boolean isUnknown(); static final int IS_NATIVE; static final int IS_UNKNOWN; }