]> git.basschouten.com Git - openhab-addons.git/blob
0e1023f49ab14d0a545fb411de14aedab5968a07
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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 com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
18 import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBDocument;
19 import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
20 import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey;
21 import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTypeConverted;
22
23 /**
24  * DynamoDBItem for items that can be serialized as DynamoDB string
25  *
26  * @author Sami Salonen - Initial contribution
27  */
28 @DynamoDBDocument
29 public class DynamoDBStringItem extends AbstractDynamoDBItem<String> {
30
31     public DynamoDBStringItem() {
32         this(null, null, null);
33     }
34
35     public DynamoDBStringItem(String name, String state, ZonedDateTime time) {
36         super(name, state, time);
37     }
38
39     @DynamoDBAttribute(attributeName = DynamoDBItem.ATTRIBUTE_NAME_ITEMSTATE)
40     @Override
41     public String getState() {
42         return state;
43     }
44
45     @DynamoDBHashKey(attributeName = DynamoDBItem.ATTRIBUTE_NAME_ITEMNAME)
46     @Override
47     public String getName() {
48         return name;
49     }
50
51     @Override
52     @DynamoDBRangeKey(attributeName = ATTRIBUTE_NAME_TIMEUTC)
53     @DynamoDBTypeConverted(converter = ZonedDateTimeConverter.class)
54     public ZonedDateTime getTime() {
55         return time;
56     }
57
58     @Override
59     public void accept(org.openhab.persistence.dynamodb.internal.DynamoDBItemVisitor visitor) {
60         visitor.visit(this);
61     }
62
63     @Override
64     public void setName(String name) {
65         this.name = name;
66     }
67
68     @Override
69     public void setState(String state) {
70         this.state = state;
71     }
72
73     @Override
74     public void setTime(ZonedDateTime time) {
75         this.time = time;
76     }
77 }