src/net/java/otr4j/session/SessionID.java
changeset 810 0ff0059f2ec3
equal deleted inserted replaced
797:fbd3585af53e 810:0ff0059f2ec3
       
     1 /*
       
     2  * otr4j, the open source java otr library.
       
     3  *
       
     4  * Distributable under LGPL license.
       
     5  * See terms of license at gnu.org.
       
     6  */
       
     7 package net.java.otr4j.session;
       
     8 
       
     9 /**
       
    10  * 
       
    11  * @author George Politis
       
    12  * 
       
    13  */
       
    14 public final class SessionID {
       
    15 
       
    16 	public SessionID(String accountID, String userID, String protocolName) {
       
    17 		this.setAccountID(accountID);
       
    18 		this.setUserID(userID);
       
    19 		this.setProtocolName(protocolName);
       
    20 	}
       
    21 
       
    22 	private String accountID;
       
    23 	private String userID;
       
    24 	private String protocolName;
       
    25 	public static final SessionID Empty = new SessionID(null, null, null);
       
    26 
       
    27 	public void setAccountID(String accountID) {
       
    28 		this.accountID = accountID;
       
    29 	}
       
    30 
       
    31 	public String getAccountID() {
       
    32 		return accountID;
       
    33 	}
       
    34 
       
    35 	private void setUserID(String userID) {
       
    36 		this.userID = userID;
       
    37 	}
       
    38 
       
    39 	public String getUserID() {
       
    40 		return userID;
       
    41 	}
       
    42 
       
    43 	private void setProtocolName(String protocolName) {
       
    44 		this.protocolName = protocolName;
       
    45 	}
       
    46 
       
    47 	public String getProtocolName() {
       
    48 		return protocolName;
       
    49 	}
       
    50 
       
    51 	public String toString() {
       
    52 		return this.getAccountID() + "_" + this.getProtocolName() + "_"
       
    53 				+ this.getUserID();
       
    54 	}
       
    55 
       
    56 	public boolean equals(Object obj) {
       
    57 		if (obj == this)
       
    58 			return true;
       
    59 		if (obj == null || obj.getClass() != this.getClass())
       
    60 			return false;
       
    61 
       
    62 		SessionID sessionID = (SessionID) obj;
       
    63 
       
    64 		return this.toString().equals(sessionID.toString());
       
    65 	}
       
    66 
       
    67 	public int hashCode() {
       
    68 		return this.toString().hashCode();
       
    69 	}
       
    70 }