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.ojelectronics.internal.services;
15 import java.util.ArrayList;
16 import java.util.List;
17 import java.util.stream.Collectors;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.ojelectronics.internal.ThermostatHandler;
21 import org.openhab.binding.ojelectronics.internal.models.groups.GroupContentModel;
22 import org.openhab.core.thing.Thing;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * Refreshes values of {@link ThermostatHandler}
29 * @author Christian Kittel - Initial Contribution
32 public class RefreshGroupContentService {
34 private final List<GroupContentModel> groupContentList;
35 private final Logger logger = LoggerFactory.getLogger(RefreshGroupContentService.class);
36 private List<Thing> things;
39 * Creates a new instance of {@link RefreshGroupContentService}
41 * @param groupContents {@link GroupContentModel}
42 * @param things Things
44 public RefreshGroupContentService(List<GroupContentModel> groupContents, List<Thing> things) {
45 this.groupContentList = groupContents;
47 if (this.things.isEmpty()) {
48 logger.warn("Bridge contains no thermostats.");
53 * Handles the changes to all things.
55 public void handle() {
56 new RefreshThermostatsService(groupContentList.stream().flatMap(entry -> entry.thermostats.stream())
57 .collect(Collectors.toCollection(ArrayList::new)), things).handle();