瀏覽代碼

Introduced an ActionMetaType interface so plugins (etc) can define their own meta-types

git-svn-id: http://svn.dmdirc.com/trunk@1017 00569f92-eb28-0410-84fd-f71c24880f
tags/0.4
Chris Smith 17 年之前
父節點
當前提交
3922bad88a

+ 43
- 0
src/uk/org/ownage/dmdirc/actions/ActionMetaType.java 查看文件

@@ -0,0 +1,43 @@
1
+/*
2
+ * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.org.ownage.dmdirc.actions;
24
+
25
+/**
26
+ * Encapsulates the methods that all action types are required to implement.
27
+ * @author chris
28
+ */
29
+public interface ActionMetaType {
30
+    
31
+    /**
32
+     * Retrieves the arity of this type.
33
+     * @return The arity of this action type
34
+     */
35
+    int getArity();
36
+    
37
+    /**
38
+     * Retrieves the type of arguments that actions of this type should expect.
39
+     * @return The type of arguments expected
40
+     */
41
+    Class[] getArgTypes();
42
+    
43
+}

+ 1
- 1
src/uk/org/ownage/dmdirc/actions/ActionType.java 查看文件

@@ -32,6 +32,6 @@ public interface ActionType {
32 32
      * Retrieves the type of this action.
33 33
      * @return This action's type
34 34
      */
35
-    CoreActionMetaType getType();
35
+    ActionMetaType getType();
36 36
     
37 37
 }

+ 4
- 12
src/uk/org/ownage/dmdirc/actions/CoreActionMetaType.java 查看文件

@@ -32,7 +32,7 @@ import uk.org.ownage.dmdirc.parser.ChannelClientInfo;
32 32
  * parameters an action expects).
33 33
  * @author chris
34 34
  */
35
-public enum CoreActionMetaType {
35
+public enum CoreActionMetaType implements ActionMetaType {
36 36
     
37 37
     SERVER_EVENT(1, Server.class),
38 38
     CHANNEL_EVENT(1, Channel.class),
@@ -53,7 +53,7 @@ public enum CoreActionMetaType {
53 53
     
54 54
     /**
55 55
      * Constructs an instance of an CoreActionMetaType.
56
-     * 
56
+     *
57 57
      * @param arity The arity of the action type
58 58
      */
59 59
     CoreActionMetaType(final int arity, final Class ... argTypes) {
@@ -61,20 +61,12 @@ public enum CoreActionMetaType {
61 61
         this.argTypes = argTypes;
62 62
     }
63 63
     
64
-    /**
65
-     * Retrieves the arity of an CoreActionMetaType.
66
-     * 
67
-     * @return The arity of this action type
68
-     */
64
+    /** {@inheritDoc} */
69 65
     public int getArity() {
70 66
         return arity;
71 67
     }
72 68
     
73
-    /**
74
-     * Retrieves the type of arguments that actiontypes of this metatype should
75
-     * expect.
76
-     * @return The type of arguments expected
77
-     */
69
+    /** {@inheritDoc} */
78 70
     public Class[] getArgTypes() {
79 71
         return argTypes.clone();
80 72
     }

+ 3
- 3
src/uk/org/ownage/dmdirc/actions/CoreActionType.java 查看文件

@@ -60,13 +60,13 @@ public enum CoreActionType implements ActionType {
60 60
     CHANNEL_TOPICCHANGE(CoreActionMetaType.CHANNEL_SOURCED_EVENT_WITH_ARG);
61 61
     
62 62
     /** The type of this action. */
63
-    private final CoreActionMetaType type;
63
+    private final ActionMetaType type;
64 64
     
65 65
     /**
66 66
      * Constructs a new core action.
67 67
      * @param type The type of this action
68 68
      */
69
-    CoreActionType(CoreActionMetaType type) {
69
+    CoreActionType(ActionMetaType type) {
70 70
         this.type = type;
71 71
     }
72 72
     
@@ -74,7 +74,7 @@ public enum CoreActionType implements ActionType {
74 74
      * Retrieves the type of this action.
75 75
      * @return This action's type
76 76
      */
77
-    public CoreActionMetaType getType() {
77
+    public ActionMetaType getType() {
78 78
         return type;
79 79
     }
80 80
     

Loading…
取消
儲存