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.unifi.internal.api.dto;
15 import com.google.gson.JsonElement;
16 import com.google.gson.JsonObject;
19 * The {@link UnfiPortOverride} represents the data model of UniFi port override.
20 * Using plain JsonObject to make sure any data in the object is not lost when writing the data back to the UniFi
23 * @author Hilbrand Bouwkamp - Initial contribution
25 public class UnfiPortOverrideJsonElement {
27 private static final String PORT_IDX = "port_idx";
28 private static final String PORT_CONF_ID = "port_conf_id";
29 private static final String POE_MODE = "poe_mode";
31 private final JsonObject jsonObject;
33 public UnfiPortOverrideJsonElement(final JsonElement element) {
34 this.jsonObject = element.getAsJsonObject();
37 public JsonObject getJsonObject() {
41 public int getPortIdx() {
42 return jsonObject.get(PORT_IDX).getAsInt();
45 public String getPortConfId() {
46 return jsonObject.get(PORT_CONF_ID).getAsString();
49 public String getPoeMode() {
50 return jsonObject.get(POE_MODE).getAsString();
53 public void setPoeMode(final String poeMode) {
54 jsonObject.addProperty(POE_MODE, poeMode);
58 public String toString() {
59 return jsonObject.toString();