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.freeboxos.internal.api.rest;
15 import java.util.List;
17 import javax.ws.rs.core.UriBuilder;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.freeboxos.internal.api.FreeboxException;
22 import org.openhab.binding.freeboxos.internal.api.Response;
25 * The {@link ListableRest} is the Java class used to handle rest answers holding a list of known equipments
27 * @author Gaƫl L'hopital - Initial contribution
30 public class ListableRest<T, Z extends Response<T>> extends RestManager {
31 private final Class<Z> deviceResponseClass;
33 protected @Nullable String listSubPath = null;
35 public ListableRest(FreeboxOsSession session, LoginManager.Permission required, Class<Z> respClass, UriBuilder uri)
36 throws FreeboxException {
37 super(session, required, uri);
38 this.deviceResponseClass = respClass;
41 public List<T> getDevices() throws FreeboxException {
42 return listSubPath == null ? get(deviceResponseClass) : get(deviceResponseClass, listSubPath);
45 public T getDevice(int deviceId) throws FreeboxException {
46 return getSingle(deviceResponseClass, Integer.toString(deviceId));