2 * Copyright (c) 2010-2020 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.types.State;
25 import org.openhab.core.types.UnDefType;
27 import tec.uom.se.AbstractUnit;
30 * The {@link CoronaStatsCountry} class holds the internal data representation of each Country
32 * @author Johannes Ott - Initial contribution
35 public class CoronaStatsCases {
36 private int cases = -1;
37 private int todayCases = -1;
38 private int deaths = -1;
39 private int todayDeaths = -1;
40 private int recovered = -1;
41 private int active = -1;
42 private int critical = -1;
44 protected Map<String, State> getCaseChannelsStateMap() {
45 Map<String, State> map = new HashMap<>();
47 map.put(CHANNEL_CASES, parseToState(cases));
48 map.put(CHANNEL_NEW_CASES, parseToState(todayCases));
49 map.put(CHANNEL_DEATHS, parseToState(deaths));
50 map.put(CHANNEL_NEW_DEATHS, parseToState(todayDeaths));
51 map.put(CHANNEL_RECOVERED, parseToState(recovered));
52 map.put(CHANNEL_ACTIVE, parseToState(active));
53 map.put(CHANNEL_CRITICAL, parseToState(critical));
58 protected State parseToState(int count) {
60 return UnDefType.NULL;
62 return new QuantityType<Dimensionless>(count, AbstractUnit.ONE);