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.util;
15 import java.lang.reflect.Type;
17 import org.openhab.binding.unifi.internal.api.model.UniFiClient;
18 import org.openhab.binding.unifi.internal.api.model.UniFiController;
19 import org.openhab.binding.unifi.internal.api.model.UniFiUnknownClient;
20 import org.openhab.binding.unifi.internal.api.model.UniFiWiredClient;
21 import org.openhab.binding.unifi.internal.api.model.UniFiWirelessClient;
23 import com.google.gson.InstanceCreator;
26 * The {@link UniFiClientInstanceCreator} creates instances of {@link UniFiClient}s during the JSON unmarshalling of
27 * controller responses.
29 * @author Matthew Bowman - Initial contribution
31 public class UniFiClientInstanceCreator implements InstanceCreator<UniFiClient> {
33 private final UniFiController controller;
35 public UniFiClientInstanceCreator(UniFiController controller) {
36 this.controller = controller;
40 public UniFiClient createInstance(Type type) {
41 if (UniFiUnknownClient.class.equals(type)) {
42 return new UniFiUnknownClient(controller);
44 if (UniFiWirelessClient.class.equals(type)) {
45 return new UniFiWirelessClient(controller);
47 if (UniFiWiredClient.class.equals(type)) {
48 return new UniFiWiredClient(controller);