]> git.basschouten.com Git - openhab-addons.git/blob
b3e92450ca32e3f8feed2860a7841c0e21c9b448
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.dynamodb.internal;
14
15 import java.time.ZonedDateTime;
16
17 import org.openhab.core.items.Item;
18 import org.openhab.core.persistence.HistoricItem;
19
20 /**
21  * Represents openHAB Item serialized in a suitable format for the database
22  *
23  * @param <T> Type of the state as accepted by the AWS SDK.
24  *
25  * @author Sami Salonen - Initial contribution
26  */
27 public interface DynamoDBItem<T> {
28
29     static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
30
31     static final String ATTRIBUTE_NAME_TIMEUTC = "timeutc";
32
33     static final String ATTRIBUTE_NAME_ITEMNAME = "itemname";
34
35     static final String ATTRIBUTE_NAME_ITEMSTATE = "itemstate";
36
37     /**
38      * Convert this AbstractDynamoItem as HistoricItem.
39      *
40      * @param item Item representing this item. Used to determine item type.
41      * @return HistoricItem representing this DynamoDBItem.
42      */
43     HistoricItem asHistoricItem(Item item);
44
45     String getName();
46
47     T getState();
48
49     ZonedDateTime getTime();
50
51     void setName(String name);
52
53     void setState(T state);
54
55     void setTime(ZonedDateTime time);
56
57     void accept(DynamoDBItemVisitor visitor);
58 }