2 * Copyright (c) 2010-2024 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.coronastats.internal.dto;
15 import static org.openhab.binding.coronastats.internal.CoronaStatsBindingConstants.*;
17 import java.util.HashMap;
20 import javax.measure.quantity.Dimensionless;
22 import org.eclipse.jdt.annotation.NonNullByDefault;
23 import org.openhab.core.library.types.QuantityType;
24 import org.openhab.core.library.unit.Units;
25 import org.openhab.core.types.State;
26 import org.openhab.core.types.UnDefType;
29 * The {@link CoronaStatsCountry} class holds the internal data representation of each Country
31 * @author Johannes Ott - Initial contribution
34 public class CoronaStatsCases {
35 private int cases = -1;
36 private int todayCases = -1;
37 private int deaths = -1;
38 private int todayDeaths = -1;
39 private int recovered = -1;
40 private int active = -1;
41 private int critical = -1;
43 protected Map<String, State> getCaseChannelsStateMap() {
44 Map<String, State> map = new HashMap<>();
46 map.put(CHANNEL_CASES, parseToState(cases));
47 map.put(CHANNEL_NEW_CASES, parseToState(todayCases));
48 map.put(CHANNEL_DEATHS, parseToState(deaths));
49 map.put(CHANNEL_NEW_DEATHS, parseToState(todayDeaths));
50 map.put(CHANNEL_RECOVERED, parseToState(recovered));
51 map.put(CHANNEL_ACTIVE, parseToState(active));
52 map.put(CHANNEL_CRITICAL, parseToState(critical));
57 protected State parseToState(int count) {
59 return UnDefType.NULL;
61 return new QuantityType<Dimensionless>(count, Units.ONE);