]> git.basschouten.com Git - openhab-addons.git/blob
9dd3a9f2c056b06c591f404880efc8d2cb616106
[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 import org.openhab.core.types.UnDefType;
22
23 /**
24  * Java bean used to return items queries results from InfluxDB.
25  *
26  * @author Theo Weiss - Initial Contribution
27  * @author Joan Pujol Espinar - Addon rewrite refactoring code and adding support for InfluxDB 2.0.
28  */
29 @NonNullByDefault
30 public class InfluxDBHistoricItem implements HistoricItem {
31
32     private String name = "";
33     private State state = UnDefType.NULL;
34     private ZonedDateTime timestamp;
35
36     public InfluxDBHistoricItem(String name, State state, ZonedDateTime timestamp) {
37         this.name = name;
38         this.state = state;
39         this.timestamp = timestamp;
40     }
41
42     @Override
43     public String getName() {
44         return name;
45     }
46
47     public void setName(String name) {
48         this.name = name;
49     }
50
51     @Override
52     public State getState() {
53         return state;
54     }
55
56     public void setState(State state) {
57         this.state = state;
58     }
59
60     @Override
61     public ZonedDateTime getTimestamp() {
62         return timestamp;
63     }
64
65     public void setTimestamp(ZonedDateTime timestamp) {
66         this.timestamp = timestamp;
67     }
68
69     @Override
70     public String toString() {
71         return DateFormat.getDateTimeInstance().format(timestamp) + ": " + name + " -> " + state.toString();
72     }
73 }