2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.miio.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
18 import com.google.gson.JsonElement;
19 import com.google.gson.JsonObject;
24 * @author Marcel Verpaalen - Initial contribution
27 public class MiIoSendCommand {
30 private final MiIoCommand command;
31 private final String commandString;
32 private @Nullable JsonObject response;
34 public void setResponse(JsonObject response) {
35 this.response = response;
38 public MiIoSendCommand(int id, MiIoCommand command, String commandString) {
40 this.command = command;
41 this.commandString = commandString;
48 public MiIoCommand getCommand() {
52 public String getCommandString() {
56 public JsonObject getResponse() {
57 final @Nullable JsonObject response = this.response;
58 return response != null ? response : new JsonObject();
61 public boolean isError() {
62 final @Nullable JsonObject response = this.response;
63 if (response != null) {
64 return response.has("error");
69 public JsonElement getResult() {
70 final @Nullable JsonObject response = this.response;
71 if (response != null && response.has("result")) {
72 return response.get("result");
74 return new JsonObject();