aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/torui/coflsky/commands/JsonStringCommand.java
diff options
context:
space:
mode:
authorFlorian Rinke <develop@torui.de>2021-11-05 20:17:35 +0100
committerFlorian Rinke <develop@torui.de>2021-11-05 20:17:35 +0100
commite533c7f6f9860479f5f472280d6fce8b87d8d0b8 (patch)
treead90d70a17908fab7325d5eee30f0c20b3192081 /src/main/java/de/torui/coflsky/commands/JsonStringCommand.java
parent0e9a5837522132b946ab1568ad0485622f32a921 (diff)
downloadCOFL-e533c7f6f9860479f5f472280d6fce8b87d8d0b8.tar.gz
COFL-e533c7f6f9860479f5f472280d6fce8b87d8d0b8.tar.bz2
COFL-e533c7f6f9860479f5f472280d6fce8b87d8d0b8.zip
rename de.torui.coflsky.core to commands in for refactor
Diffstat (limited to 'src/main/java/de/torui/coflsky/commands/JsonStringCommand.java')
-rw-r--r--src/main/java/de/torui/coflsky/commands/JsonStringCommand.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/java/de/torui/coflsky/commands/JsonStringCommand.java b/src/main/java/de/torui/coflsky/commands/JsonStringCommand.java
new file mode 100644
index 0000000..6bc22d8
--- /dev/null
+++ b/src/main/java/de/torui/coflsky/commands/JsonStringCommand.java
@@ -0,0 +1,28 @@
+package de.torui.coflsky.commands;
+
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+
+public class JsonStringCommand extends Command<String> {
+
+ public JsonStringCommand(String type, String data) {
+ this.setType(CommandType.valueOf(type));
+ this.setData(data);
+ }
+
+ public JsonStringCommand() {
+ super();
+
+ }
+
+ public JsonStringCommand(CommandType type, String data) {
+ super(type, data);
+ }
+
+ public <T> Command<T> GetAs(TypeToken<T> type){
+ T t = new GsonBuilder().create().fromJson(this.getData(),type.getType());
+ Command<?> cmd = new Command<Object>(this.getType(), t);
+
+ return (Command<T>) cmd;
+ }
+}