]> git.basschouten.com Git - openhab-addons.git/blob
3e00466e5e02fd4d5a9da1647cc47cca32aa9455
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.persistence.influxdb.internal;
14
15 import java.text.DateFormat;
16 import java.time.ZonedDateTime;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.core.persistence.HistoricItem;
20 import org.openhab.core.types.State;
21
22 /**
23  * Java bean used to return items queries results from InfluxDB.
24  *
25  * @author Theo Weiss - Initial Contribution
26  * @author Joan Pujol Espinar - Addon rewrite refactoring code and adding support for InfluxDB 2.0.
27  */
28 @NonNullByDefault
29 public class InfluxDBHistoricItem implements HistoricItem {
30
31     private String name = "";
32     private final State state;
33     private final ZonedDateTime timestamp;
34
35     public InfluxDBHistoricItem(String name, State state, ZonedDateTime timestamp) {
36         this.name = name;
37         this.state = state;
38         this.timestamp = timestamp;
39     }
40
41     @Override
42     public String getName() {
43         return name;
44     }
45
46     public void setName(String name) {
47         this.name = name;
48     }
49
50     @Override
51     public State getState() {
52         return state;
53     }
54
55     @Override
56     public ZonedDateTime getTimestamp() {
57         return timestamp;
58     }
59
60     @Override
61     public String toString() {
62         return DateFormat.getDateTimeInstance().format(timestamp) + ": " + name + " -> " + state.toString();
63     }
64 }