blob: e1dad6045640fbaaf71e04319fdc8d1c73dc90d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
package f00f.net.irc.martyr.modes;
import f00f.net.irc.martyr.Mode;
/**
* GenericNode uses the character to specify the hash code. Thus, two
* mode types are the same, in a hash table, even if they have
* different parameters or positive/negative values.
*/
public abstract class GenericMode implements Mode
{
private String str;
private Mode.Sign sign = Mode.Sign.NOSIGN;
public void setParam( String str )
{
this.str = str;
}
public String getParam()
{
return str;
}
public void setSign( Mode.Sign sign )
{
this.sign = sign;
}
public Mode.Sign getSign()
{
return sign;
}
public String toString()
{
String pString = " ";
if( sign != Mode.Sign.NOSIGN )
pString += ( sign == Mode.Sign.POSITIVE ? "+" : "-" );
String className = this.getClass().getName();
className = className.substring( className.indexOf('$')+1 );
String result = className + pString + getChar();
if( requiresParam() )
{
result += " " + getParam();
}
return result;
}
public boolean equals( Object o )
{
if( o instanceof Mode )
{
Mode oMode = (Mode)o;
if( oMode.getParam() == null || this.getParam() == null )
return oMode.getChar() == this.getChar();
if( oMode.getParam() == null && this.getParam() != null )
return false;
if( oMode.getParam() == null && this.getParam() == null )
return oMode.getChar() == this.getChar();
return oMode.getChar() == this.getChar() &&
oMode.getParam().equals(this.getParam());
}
return false;
}
public int hashCode()
{
return (int)getChar();
}
}
|