Преглед на файлове

Start work on 'auto commands'.

This is going to replace the perform wrappers. Better name
suggestions on a postcard.

Change-Id: I19fc055d275d25cf9c24fe8a56cba73ea24c2b6a
Reviewed-on: http://gerrit.dmdirc.com/3664
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
pull/1/head
Chris Smith преди 9 години
родител
ревизия
a4921dd375
променени са 2 файла, в които са добавени 115 реда и са изтрити 0 реда
  1. 69
    0
      src/com/dmdirc/commandparser/auto/AutoCommand.java
  2. 46
    0
      src/com/dmdirc/commandparser/auto/AutoCommandStore.java

+ 69
- 0
src/com/dmdirc/commandparser/auto/AutoCommand.java Целия файл

@@ -0,0 +1,69 @@
1
+/*
2
+ * Copyright (c) 2006-2014 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.commandparser.auto;
24
+
25
+import com.google.common.base.Optional;
26
+
27
+/**
28
+ * Describes a command that is executed automatically in response to either the client opening, or a
29
+ * server connecting.
30
+ */
31
+public class AutoCommand {
32
+
33
+    /** The name of the server for connection events. */
34
+    private final Optional<String> server;
35
+    /** The name of the network for connection events. */
36
+    private final Optional<String> network;
37
+    /** The name of the profile for connection events. */
38
+    private final Optional<String> profile;
39
+    /** The commands to execute. */
40
+    private final String response;
41
+
42
+    public AutoCommand(
43
+            final Optional<String> server,
44
+            final Optional<String> network,
45
+            final Optional<String> profile,
46
+            final String response) {
47
+        this.server = server;
48
+        this.network = network;
49
+        this.profile = profile;
50
+        this.response = response;
51
+    }
52
+
53
+    public Optional<String> getServer() {
54
+        return server;
55
+    }
56
+
57
+    public Optional<String> getNetwork() {
58
+        return network;
59
+    }
60
+
61
+    public Optional<String> getProfile() {
62
+        return profile;
63
+    }
64
+
65
+    public String getResponse() {
66
+        return response;
67
+    }
68
+
69
+}

+ 46
- 0
src/com/dmdirc/commandparser/auto/AutoCommandStore.java Целия файл

@@ -0,0 +1,46 @@
1
+/*
2
+ * Copyright (c) 2006-2014 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.commandparser.auto;
24
+
25
+import java.util.Set;
26
+
27
+/**
28
+ * A store of {@link AutoCommand}s that can read and write them to some kind of persistent media.
29
+ */
30
+public interface AutoCommandStore {
31
+
32
+    /**
33
+     * Reads and returns all auto commands from within the store.
34
+     *
35
+     * @return A set of known auto commands, or an empty set if the store is uninitialised.
36
+     */
37
+    Set<AutoCommand> readAutoCommands();
38
+
39
+    /**
40
+     * Writes all the given auto commands to the store, replacing any existing commands.
41
+     *
42
+     * @param aliases The set of auto command to be written to the store.
43
+     */
44
+    void writeAutoCommands(Set<AutoCommand> aliases);
45
+
46
+}

Loading…
Отказ
Запис