AuthorizableImpl implements Authorizable, UserConstants { @Override public int hashCode() { if (hashCode == 0) { StringBuilder sb = new StringBuilder(); sb.append(isGroup() ? "group:" : "user:"); sb.append(':'); sb.append(id); sb.append('_'); sb.append(userManager.hashCode()); hashCode = sb.toString().hashCode(); } return hashCode; } AuthorizableImpl(@NotNull String id, @NotNull Tree tree,
                     @NotNull UserManagerImpl userManager); @NotNull @Override String getID(); @NotNull @Override Iterator<Group> declaredMemberOf(); @NotNull @Override Iterator<Group> memberOf(); @Override void remove(); @NotNull @Override Iterator<String> getPropertyNames(); @NotNull @Override Iterator<String> getPropertyNames(@NotNull String relPath); @Override boolean hasProperty(@NotNull String relPath); @Nullable @Override Value[] getProperty(@NotNull String relPath); @Override void setProperty(@NotNull String relPath, @Nullable Value value); @Override void setProperty(@NotNull String relPath, @Nullable Value[] values); @Override boolean removeProperty(@NotNull String relPath); @NotNull @Override String getPath(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testHashCode() throws Exception { Authorizable user = userMgr.getAuthorizable(testUser.getID()); Authorizable group = userMgr.getAuthorizable(testGroup.getID()); Map<Authorizable, Authorizable> sameHashCode = new HashMap<>(); sameHashCode.put(testUser, testUser); sameHashCode.put(testGroup, testGroup); sameHashCode.put(user, user); sameHashCode.put(group, group); sameHashCode.put(testUser, user); sameHashCode.put(testGroup, group); for (Map.Entry entry : sameHashCode.entrySet()) { assertEquals(entry.getKey().hashCode(), entry.getValue().hashCode()); } UserManager otherUserManager = getUserConfiguration().getUserManager(root, getNamePathMapper()); user = otherUserManager.getAuthorizable(testUser.getID()); group = otherUserManager.getAuthorizable(testGroup.getID()); Map<Authorizable, Authorizable> notSameHashCode = new HashMap<>(); notSameHashCode.put(testUser, testGroup); notSameHashCode.put(user, group); notSameHashCode.put(testUser, user); notSameHashCode.put(testGroup, group); for (Map.Entry entry : notSameHashCode.entrySet()) { assertNotEquals(entry.getKey().hashCode(), entry.getValue().hashCode()); } }