2 * Copyright (c) 2010-2022 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.digitalstrom.internal.lib.structure.devices.deviceparameters.impl;
15 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.constants.JSONApiResponseKeysEnum;
16 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.DeviceConfig;
18 import com.google.gson.JsonObject;
21 * The {@link JSONDeviceConfigImpl} is the implementation of the {@link DeviceConfig}.
23 * @author Alexander Betker - initial contributer
24 * @author Michael Ochel - change from SimpleJSON to GSON
25 * @author Matthias Siegele - change from SimpleJSON to GSON
27 public class JSONDeviceConfigImpl implements DeviceConfig {
29 private int class_ = -1;
30 private int index = -1;
31 private int value = -1;
34 * Creates a new {@link JSONDeviceConfigImpl}.
36 * @param object must not be null
38 public JSONDeviceConfigImpl(JsonObject object) {
39 if (object.get(JSONApiResponseKeysEnum.CLASS.getKey()) != null) {
40 class_ = object.get(JSONApiResponseKeysEnum.CLASS.getKey()).getAsInt();
42 if (object.get(JSONApiResponseKeysEnum.INDEX.getKey()) != null) {
43 index = object.get(JSONApiResponseKeysEnum.INDEX.getKey()).getAsInt();
45 if (object.get(JSONApiResponseKeysEnum.VALUE.getKey()) != null) {
46 value = object.get(JSONApiResponseKeysEnum.VALUE.getKey()).getAsInt();
51 public int getConfigurationClass() {
56 public int getIndex() {
61 public int getValue() {
66 public String toString() {
67 return "class: " + this.class_ + ", " + "index: " + this.index + ", " + "value: " + this.value;