src/net/java/otr4j/session/SessionID.java
changeset 810 0ff0059f2ec3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/net/java/otr4j/session/SessionID.java	Sun Dec 05 18:43:51 2010 +0100
@@ -0,0 +1,70 @@
+/*
+ * otr4j, the open source java otr library.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.otr4j.session;
+
+/**
+ * 
+ * @author George Politis
+ * 
+ */
+public final class SessionID {
+
+	public SessionID(String accountID, String userID, String protocolName) {
+		this.setAccountID(accountID);
+		this.setUserID(userID);
+		this.setProtocolName(protocolName);
+	}
+
+	private String accountID;
+	private String userID;
+	private String protocolName;
+	public static final SessionID Empty = new SessionID(null, null, null);
+
+	public void setAccountID(String accountID) {
+		this.accountID = accountID;
+	}
+
+	public String getAccountID() {
+		return accountID;
+	}
+
+	private void setUserID(String userID) {
+		this.userID = userID;
+	}
+
+	public String getUserID() {
+		return userID;
+	}
+
+	private void setProtocolName(String protocolName) {
+		this.protocolName = protocolName;
+	}
+
+	public String getProtocolName() {
+		return protocolName;
+	}
+
+	public String toString() {
+		return this.getAccountID() + "_" + this.getProtocolName() + "_"
+				+ this.getUserID();
+	}
+
+	public boolean equals(Object obj) {
+		if (obj == this)
+			return true;
+		if (obj == null || obj.getClass() != this.getClass())
+			return false;
+
+		SessionID sessionID = (SessionID) obj;
+
+		return this.toString().equals(sessionID.toString());
+	}
+
+	public int hashCode() {
+		return this.toString().hashCode();
+	}
+}