@Test public void testEqualsObject() { assertTrue(user.equals(user)); assertTrue(user.equals(new UserImpl(login, realm, name))); assertTrue(user.equals(new UserImpl(login, realm))); assertFalse(user.equals(new UserImpl(login, "wonderland"))); assertFalse(user.equals(new UserImpl("james", realm))); }
@Override public boolean equals(Object obj) { if (obj instanceof User) { User u = (User) obj; if (realm != null && !realm.equals(u.getRealm())) return false; if (u.getRealm() != null && realm == null) return false; return login.equals(u.getLogin()); } return super.equals(obj); }
UserImpl implements User { @Override public boolean equals(Object obj) { if (obj instanceof User) { User u = (User) obj; if (realm != null && !realm.equals(u.getRealm())) return false; if (u.getRealm() != null && realm == null) return false; return login.equals(u.getLogin()); } return super.equals(obj); } }
UserImpl implements User { @Override public boolean equals(Object obj) { if (obj instanceof User) { User u = (User) obj; if (realm != null && !realm.equals(u.getRealm())) return false; if (u.getRealm() != null && realm == null) return false; return login.equals(u.getLogin()); } return super.equals(obj); } UserImpl(String login);  UserImpl(String login, boolean authenticated);  UserImpl(String login, String realm);  UserImpl(String login, String realm, boolean authenticated);  UserImpl(String login, String realm, String name);  UserImpl(String login, String realm, String name, boolean authenticated);  UserImpl(User user); }
UserImpl implements User { @Override public boolean equals(Object obj) { if (obj instanceof User) { User u = (User) obj; if (realm != null && !realm.equals(u.getRealm())) return false; if (u.getRealm() != null && realm == null) return false; return login.equals(u.getLogin()); } return super.equals(obj); } UserImpl(String login);  UserImpl(String login, boolean authenticated);  UserImpl(String login, String realm);  UserImpl(String login, String realm, boolean authenticated);  UserImpl(String login, String realm, String name);  UserImpl(String login, String realm, String name, boolean authenticated);  UserImpl(User user); @Override void setAuthenticated(boolean authenticated); @Override boolean isAuthenticated(); String getLogin(); void setName(String name); String getName(); void setRealm(String realm); String getRealm(); void addPrivateCredentials(Object... credentials); boolean removePrivateCredentials(Object credentials); Set<Object> getPrivateCredentials(); Set<Object> getPrivateCredentials(Class<?> type); void addPublicCredentials(Object... credentials); boolean removePublicCredentials(Object credentials); Set<Object> getPublicCredentials(); Set<Object> getPublicCredentials(Class<?> type); static UserImpl fromXml(Node xml); static UserImpl fromXml(Node xml, XPath xpath); @Override Object clone(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); String toXml(); @Override String getAuthorityType(); @Override String getAuthorityId(); @Override boolean implies(Authority authority); @Override boolean matches(Authority authority); }
UserImpl implements User { @Override public boolean equals(Object obj) { if (obj instanceof User) { User u = (User) obj; if (realm != null && !realm.equals(u.getRealm())) return false; if (u.getRealm() != null && realm == null) return false; return login.equals(u.getLogin()); } return super.equals(obj); } UserImpl(String login);  UserImpl(String login, boolean authenticated);  UserImpl(String login, String realm);  UserImpl(String login, String realm, boolean authenticated);  UserImpl(String login, String realm, String name);  UserImpl(String login, String realm, String name, boolean authenticated);  UserImpl(User user); @Override void setAuthenticated(boolean authenticated); @Override boolean isAuthenticated(); String getLogin(); void setName(String name); String getName(); void setRealm(String realm); String getRealm(); void addPrivateCredentials(Object... credentials); boolean removePrivateCredentials(Object credentials); Set<Object> getPrivateCredentials(); Set<Object> getPrivateCredentials(Class<?> type); void addPublicCredentials(Object... credentials); boolean removePublicCredentials(Object credentials); Set<Object> getPublicCredentials(); Set<Object> getPublicCredentials(Class<?> type); static UserImpl fromXml(Node xml); static UserImpl fromXml(Node xml, XPath xpath); @Override Object clone(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); String toXml(); @Override String getAuthorityType(); @Override String getAuthorityId(); @Override boolean implies(Authority authority); @Override boolean matches(Authority authority);  }