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.coronastats.internal.dto;
15 import static org.openhab.binding.coronastats.internal.CoronaStatsBindingConstants.*;
17 import java.time.ZoneId;
18 import java.time.ZonedDateTime;
19 import java.util.Collections;
20 import java.util.Date;
21 import java.util.HashMap;
24 import org.eclipse.jdt.annotation.NonNullByDefault;
25 import org.openhab.core.library.types.DateTimeType;
26 import org.openhab.core.types.State;
27 import org.openhab.core.types.UnDefType;
30 * The {@link CoronaStatsCountry} class holds the internal data representation of each Country
32 * @author Johannes Ott - Initial contribution
35 public class CoronaStatsCountry extends CoronaStatsCases {
36 private String country = "";
37 private String countryCode = "";
38 private int tests = -1;
39 private long updated = -1;
41 public String getCountryCode() {
45 public Map<String, String> getProperties() {
46 Map<String, String> map = new HashMap<>();
47 map.put(PROPERTY_COUNTRY, country);
48 return Collections.unmodifiableMap(map);
51 public Map<String, State> getChannelsStateMap() {
52 Map<String, State> map = super.getCaseChannelsStateMap();
54 map.put(CHANNEL_TESTS, parseToState(tests));
57 map.put(CHANNEL_UPDATED, UnDefType.NULL);
59 Date date = new Date(updated);
60 ZonedDateTime zoned = ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
61 map.put(CHANNEL_UPDATED, new DateTimeType(zoned));
64 return Collections.unmodifiableMap(map);