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.binding.unifi.internal.api.dto;
15 import com.google.gson.JsonObject;
18 * The {@link UnfiPortOverride} represents the data model of UniFi port override.
19 * Using plain JsonObject to make sure any data in the object is not lost when writing the data back to the UniFi
22 * @author Hilbrand Bouwkamp - Initial contribution
24 public class UnfiPortOverrideJsonObject {
26 private static final String PORT_IDX = "port_idx";
27 private static final String PORT_CONF_ID = "port_conf_id";
28 private static final String POE_MODE = "poe_mode";
30 private final JsonObject jsonObject;
32 public UnfiPortOverrideJsonObject(final JsonObject Object) {
33 this.jsonObject = Object.getAsJsonObject();
36 public JsonObject getJsonObject() {
40 public static boolean hasPortIdx(final JsonObject jsonObject) {
41 return jsonObject.has(PORT_IDX);
44 public int getPortIdx() {
45 return jsonObject.get(PORT_IDX).getAsInt();
48 public String getPortConfId() {
49 return jsonObject.get(PORT_CONF_ID).getAsString();
52 public String getPoeMode() {
53 return jsonObject.get(POE_MODE).getAsString();
56 public void setPoeMode(final String poeMode) {
57 jsonObject.addProperty(POE_MODE, poeMode);
61 public String toString() {
62 return jsonObject.toString();