00001 /* 00002 * User.java 00003 * 00004 * Created on May 14, 2005, 1:18 PM 00005 * Created by Detro - 566/2145 00006 */ 00007 00008 package org.jaebi.server.core; 00009 import org.jaebi.server.auth.Session; 00016 public class User { 00017 private final String nick; 00018 private final Session session; 00019 private final String type; 00020 00022 public User(String newNick, Session newSession, String newType) { 00023 nick = newNick; 00024 session = newSession; 00025 type = newType; 00026 } 00027 00028 public String getNick() { 00029 return nick; 00030 } 00031 00032 public Session getSession() { 00033 return session; 00034 } 00035 00036 public String getType() { 00037 return type; 00038 } 00039 00040 public boolean equals( Object obj ) { 00041 if( obj == this ) { 00042 return true; 00043 } 00044 if( obj.getClass() == this.getClass() ) { 00045 User user = ( User ) obj; 00046 /* Questo controllo e' necessario perche' Session 00047 * potrebbe non essere "unico" per scelte implementative */ 00048 if( user.getNick().equals(this.getNick()) && 00049 user.getSession().equals(this.getSession()) && 00050 user.getType().equals(this.getType()) 00051 ) { 00052 return true; 00053 } 00054 } 00055 return false; 00056 } 00057 00058 public int hashCode() { 00059 return toString().hashCode(); 00060 } 00061 00062 public String toString() { 00063 return "Nick: " + getNick() + " - " + 00064 "Session: " + getSession().toString() + " - " + 00065 "Type: " + getType(); 00066 } 00067 00068 }