SessionIdentifier { @Override public boolean equals(final Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } final SessionIdentifier that = (SessionIdentifier) other; if (userId != that.userId) { return false; } if (context != that.context) { return false; } return sessionId.equals(that.sessionId); } SessionIdentifier(
        final long userId,
        @NotNull final String sessionId,
        @NotNull final Context context
    ); long getUserId(); String getSessionId(); Context getContext(); @Override boolean equals(final Object other); @Override int hashCode(); @Override String toString(); static SessionIdentifier newWebIdentifier(final long userId, final String sessionId); static SessionIdentifier newStreamIdentifier(final long userId, final String sessionId);  }
@Test public void testEquals() { final SessionIdentifier id1 = new SessionIdentifier(12L, "MySession", SessionIdentifier.Context.WEB); final SessionIdentifier id2 = new SessionIdentifier(12L, "MySession", SessionIdentifier.Context.WEB); final SessionIdentifier id3 = new SessionIdentifier(12L, "YourSession", SessionIdentifier.Context.WEB); final SessionIdentifier id4 = new SessionIdentifier(13L, "MySession", SessionIdentifier.Context.WEB); final SessionIdentifier id5 = new SessionIdentifier(13L, "MySession", SessionIdentifier.Context.STREAM); assertTrue("Should be equal", id1.equals(id1)); assertTrue("Should be equal", id1.equals(id2)); assertFalse("Should NOT be equal", id1.equals(null)); assertFalse("Should NOT be equal", id1.equals(id3)); assertFalse("Should NOT be equal", id1.equals(id4)); assertFalse("Should NOT be equal", id3.equals(id4)); assertFalse("Should NOT be equal", id4.equals(id5)); }