@Test public void testHashCode() throws Exception { Method method1 = Object.class.getDeclaredMethod("equals", Object.class); Method method2 = Object.class.getDeclaredMethod("toString"); Object commonObject = new Object(); SoapCall<Object> soapCall1 = new SoapCall<Object>(method1, commonObject, new Integer[] {5}); SoapCall<Object> soapCall2 = new SoapCall<Object>(method2, commonObject, new Integer[] {5}); SoapCall<Object> soapCall3 = new SoapCall<Object>(method1, commonObject, new Integer[] {42}); SoapCall<Object> soapCall4 = new SoapCall<Object>(method1, new Object(), new Integer[] {42}); assertTrue("Hash code is not stable", soapCall1.hashCode() == soapCall1.hashCode()); assertFalse( "Hash code unaffected by method change", soapCall1.hashCode() == soapCall2.hashCode()); assertFalse( "Hash code unaffected by array change", soapCall1.hashCode() == soapCall3.hashCode()); assertFalse( "Hash code unaffected by array change", soapCall1.hashCode() == soapCall3.hashCode()); assertFalse( "Hash code unaffected by client change", soapCall1.hashCode() == soapCall4.hashCode()); }
@Override public int hashCode() { return Objects.hash(soapClientMethod, soapClient, Arrays.hashCode(soapArgs)); }
SoapCall { @Override public int hashCode() { return Objects.hash(soapClientMethod, soapClient, Arrays.hashCode(soapArgs)); } }
SoapCall { @Override public int hashCode() { return Objects.hash(soapClientMethod, soapClient, Arrays.hashCode(soapArgs)); } SoapCall(Method soapClientMethod, T soapClient, Object[] soapArgs); }
SoapCall { @Override public int hashCode() { return Objects.hash(soapClientMethod, soapClient, Arrays.hashCode(soapArgs)); } SoapCall(Method soapClientMethod, T soapClient, Object[] soapArgs); Method getSoapClientMethod(); T getSoapClient(); Object[] getSoapArgs(); @Override boolean equals(Object obj); @Override int hashCode(); }
SoapCall { @Override public int hashCode() { return Objects.hash(soapClientMethod, soapClient, Arrays.hashCode(soapArgs)); } SoapCall(Method soapClientMethod, T soapClient, Object[] soapArgs); Method getSoapClientMethod(); T getSoapClient(); Object[] getSoapArgs(); @Override boolean equals(Object obj); @Override int hashCode();  }