|
@@ -0,0 +1,89 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright (c) 2006-2013 DMDirc Developers
|
|
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 com.dmdirc.actions;
|
|
24
|
+
|
|
25
|
+import com.dmdirc.interfaces.actions.ActionType;
|
|
26
|
+
|
|
27
|
+import java.util.List;
|
|
28
|
+import javax.inject.Inject;
|
|
29
|
+
|
|
30
|
+/**
|
|
31
|
+ * Factory for creating {@link Action}s.
|
|
32
|
+ */
|
|
33
|
+public class ActionFactory {
|
|
34
|
+
|
|
35
|
+ /**
|
|
36
|
+ * Creates a new instance of {@link ActionFactory}.
|
|
37
|
+ */
|
|
38
|
+ @Inject
|
|
39
|
+ public ActionFactory() {
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ /**
|
|
43
|
+ * Creates a new instance of Action. The group and name specified must
|
|
44
|
+ * be the group and name of a valid action already saved to disk.
|
|
45
|
+ *
|
|
46
|
+ * @param group The group the action belongs to
|
|
47
|
+ * @param name The name of the action
|
|
48
|
+ */
|
|
49
|
+ public Action create(final String group, final String name) {
|
|
50
|
+ return new Action(group, name);
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ /**
|
|
54
|
+ * Creates a new instance of Action with the specified properties and saves
|
|
55
|
+ * it to disk.
|
|
56
|
+ *
|
|
57
|
+ * @param group The group the action belongs to
|
|
58
|
+ * @param name The name of the action
|
|
59
|
+ * @param triggers The triggers to use
|
|
60
|
+ * @param response The response to use
|
|
61
|
+ * @param conditions The conditions to use
|
|
62
|
+ * @param newFormat The new formatter to use
|
|
63
|
+ */
|
|
64
|
+ public Action create(final String group, final String name,
|
|
65
|
+ final ActionType[] triggers, final String[] response,
|
|
66
|
+ final List<ActionCondition> conditions, final String newFormat) {
|
|
67
|
+ return new Action(group, name, triggers, response, conditions, newFormat);
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ /**
|
|
71
|
+ * Creates a new instance of Action with the specified properties and saves
|
|
72
|
+ * it to disk.
|
|
73
|
+ *
|
|
74
|
+ * @param group The group the action belongs to
|
|
75
|
+ * @param name The name of the action
|
|
76
|
+ * @param triggers The triggers to use
|
|
77
|
+ * @param response The response to use
|
|
78
|
+ * @param conditions The conditions to use
|
|
79
|
+ * @param conditionTree The condition tree to use
|
|
80
|
+ * @param newFormat The new formatter to use
|
|
81
|
+ */
|
|
82
|
+ public Action create(final String group, final String name,
|
|
83
|
+ final ActionType[] triggers, final String[] response,
|
|
84
|
+ final List<ActionCondition> conditions,
|
|
85
|
+ final ConditionTree conditionTree, final String newFormat) {
|
|
86
|
+ return new Action(group, name, triggers, response, conditions, conditionTree, newFormat);
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+}
|