From e533c7f6f9860479f5f472280d6fce8b87d8d0b8 Mon Sep 17 00:00:00 2001 From: Florian Rinke Date: Fri, 5 Nov 2021 20:17:35 +0100 Subject: rename de.torui.coflsky.core to commands in for refactor --- .../torui/coflsky/commands/JsonStringCommand.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/de/torui/coflsky/commands/JsonStringCommand.java (limited to 'src/main/java/de/torui/coflsky/commands/JsonStringCommand.java') 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 { + + 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 Command GetAs(TypeToken type){ + T t = new GsonBuilder().create().fromJson(this.getData(),type.getType()); + Command cmd = new Command(this.getType(), t); + + return (Command) cmd; + } +} -- cgit