FullJidAndSessionId.java

  1. /**
  2.  *
  3.  * Copyright 2017 Florian Schmaus, Paul Schaub
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smackx.jingle;

  18. import org.jxmpp.jid.FullJid;

  19. /**
  20.  * Pair of jid and sessionId.
  21.  */
  22. public class FullJidAndSessionId {
  23.     private final FullJid fullJid;
  24.     private final String sessionId;

  25.     public FullJidAndSessionId(FullJid fullJid, String sessionId) {
  26.         this.fullJid = fullJid;
  27.         this.sessionId = sessionId;
  28.     }

  29.     public FullJid getFullJid() {
  30.         return fullJid;
  31.     }

  32.     public String getSessionId() {
  33.         return sessionId;
  34.     }

  35.     @Override
  36.     public int hashCode() {
  37.         int hashCode = 31 * fullJid.hashCode();
  38.         hashCode = 31 * hashCode + sessionId.hashCode();
  39.         return hashCode;
  40.     }

  41.     @Override
  42.     public boolean equals(Object other) {
  43.         if (!(other instanceof FullJidAndSessionId)) {
  44.             return false;
  45.         }
  46.         FullJidAndSessionId otherFullJidAndSessionId = (FullJidAndSessionId) other;
  47.         return fullJid.equals(otherFullJidAndSessionId.fullJid)
  48.                 && sessionId.equals(otherFullJidAndSessionId.sessionId);
  49.     }
  50. }