summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/src/f00f/net/irc/martyr/Mode.java
blob: 5cc39e1a9d1e5f70a8a2d2d477f61c629092c3b1 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package f00f.net.irc.martyr;

/**
 * Any class which is to represent a mode must implement this
 * interface.  They must also implement equals(...) so that if the
 * parameter for either mode is null they are equal based on the
 * character, and if both parameters are not null, base the equal
 * on the character and the parameters being equal.
 */
public interface Mode
{
	/**
	 * A Mode can be constructed and asked to make copies of itself.
     *
     * @return New Mode instance
	 */
	Mode newInstance();
	
	/**
	 * The character that represents this mode (ie o for operator)
     *
     * @return Character representation of mode
	 */
	char getChar();
	
	/**
	 * Should return true if this mode requires a parameter.
     *
     * @return True or false if a param is required for mode
	 */
	boolean requiresParam();

	/**
	 * This mode should be recorded in the list of channel modes.  This
	 * would NOT include such things as operator status, as it is recored
	 * with the Member object.
     *
     * @return True or false of the mode should be recorded in the list of channels
	 */
	boolean recordInChannel();
	
	/**
	 * Determines if there can be multiple versions of this mode in
	 * the channel.
     *
     * @return True or false if only one instance of mode can exist per channel
	 */
	boolean onePerChannel();
	
	/**
	 * Returns the parameter that was set with setParam(...)
     *
     * @return Parameter that was set previously
	 */
	String getParam();
	
	/**
	 * Sets the parameter that can be retrieved with getParam()
     *
     * @param str Parameter to set on mode
	 */
	void setParam( String str );
	
	/**
	 * Sets the sign of the operation.  Must be positive (granting),
	 * negative (revoking) or nosign (neutral operation).
     *
     * @param sign Sign (+/-) of the mode
	 */
	void setSign( Sign sign );
	
	/**
	 * @return the sign of this mode.
	 */
	Sign getSign();

	/**
	 * Finally, the Sign enumeration.
	 */
	public class Sign
	{
		public static final Sign POSITIVE = new Sign( "positive" );
		public static final Sign NEGATIVE = new Sign( "negative" );
		public static final Sign NOSIGN = new Sign( "nosign" );
	
		private String name;
		private Sign( String name )
		{
			this.name = name;
		}
	
		public String toString()
		{
			return name;
		}
	}
	
}