O2Principal implements Principal { @Override public int hashCode() { return Objects.hashCode(getScheme(), getContext(), getOAuthToken()); } O2Principal();  O2Principal(final Client client);  O2Principal(final OAuthToken token); private  O2Principal(final Client client, final OAuthToken token); OAuthToken getOAuthToken(); @Override String getName(); @Override boolean implies(final Subject subject); String getScheme(); Client getContext(); O2Principal merge(final Principal newPrincipal); @Override boolean equals(final Object o); @Override int hashCode();  }
@Test public void testHashCode() { Client c1 = new Client(); c1.setId(IdUtil.next()); c1.setClientSecret("secret"); O2Principal p1 = new O2Principal(c1); Client cSame = new Client(); cSame.setId(c1.getId()); cSame.setClientSecret(c1.getClientSecret()); O2Principal pSame = new O2Principal(cSame); Client c2 = new Client(); c2.setId(IdUtil.next()); c2.setClientSecret("other_secret"); O2Principal p2 = new O2Principal(c2); assertEquals(p1.hashCode(), pSame.hashCode()); assertNotEquals(p1.hashCode(), p2.hashCode()); assertNotEquals(pSame.hashCode(), p2.hashCode()); }