2 * Copyright (c) 2010-2023 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.io.hueemulation.internal.dto.response;
15 import java.lang.reflect.Type;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
20 import com.google.gson.JsonElement;
21 import com.google.gson.JsonObject;
22 import com.google.gson.JsonSerializationContext;
23 import com.google.gson.JsonSerializer;
26 * This object describes the right hand side of "success".
28 * @author David Graeff - Initial contribution
31 public class HueSuccessGeneric extends HueSuccessResponse {
32 public String message;
33 public transient String key;
35 public HueSuccessGeneric(@Nullable Object message, String key) {
36 this.message = message != null ? String.valueOf(message) : "";
40 public static class Serializer implements JsonSerializer<HueSuccessGeneric> {
43 public JsonElement serialize(HueSuccessGeneric product, Type type, JsonSerializationContext jsc) {
44 JsonObject jObj = new JsonObject();
45 jObj.addProperty(product.key, product.message);
50 public boolean isValid() {
51 return !message.isEmpty();