]> git.basschouten.com Git - openhab-addons.git/blob
dd3539b98b33960e687ccf14f3e5b4c915128c7a
[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.jdbc.internal.dto;
14
15 import java.io.Serializable;
16 import java.util.Date;
17 import java.util.Objects;
18
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 /**
24  * Represents the Item-data on the part of MyBatis/database.
25  *
26  * @author Helmut Lehmeyer - Initial contribution
27  */
28 public class ItemVO implements Serializable {
29     private final Logger logger = LoggerFactory.getLogger(ItemVO.class);
30
31     private static final long serialVersionUID = 1871441039821454890L;
32
33     private String tableName;
34     private @Nullable String newTableName;
35     private String dbType;
36     private String jdbcType;
37     private String itemType;
38     private Class<?> javaType;
39     private Date time;
40     private Object value;
41
42     public ItemVO(String tableName, @Nullable String newTableName) {
43         logger.debug("JDBC:ItemVO tableName={}; newTableName={}; ", tableName, newTableName);
44         this.tableName = tableName;
45         this.newTableName = newTableName;
46     }
47
48     public ItemVO() {
49     }
50
51     public void setValueTypes(String dbType, Class<?> javaType) {
52         logger.debug("JDBC:ItemVO setValueTypes dbType={}; javaType={};", dbType, javaType);
53         this.dbType = dbType;
54         this.javaType = javaType;
55     }
56
57     public String getTableName() {
58         return tableName;
59     }
60
61     public void setTableName(String tableName) {
62         this.tableName = tableName;
63     }
64
65     public @Nullable String getNewTableName() {
66         return newTableName;
67     }
68
69     public void setNewTableName(String newTableName) {
70         this.newTableName = newTableName;
71     }
72
73     public String getDbType() {
74         return dbType;
75     }
76
77     public void setDbType(String dbType) {
78         this.dbType = dbType;
79     }
80
81     public String getJdbcType() {
82         return jdbcType;
83     }
84
85     public void setJdbcType(String jdbcType) {
86         this.jdbcType = jdbcType;
87     }
88
89     public String getItemType() {
90         return itemType;
91     }
92
93     public void setItemType(String itemType) {
94         this.itemType = itemType;
95     }
96
97     public String getJavaType() {
98         return javaType.getName();
99     }
100
101     public void setJavaType(Class<?> javaType) {
102         this.javaType = javaType;
103     }
104
105     public Date getTime() {
106         return time;
107     }
108
109     public void setTime(Date time) {
110         this.time = time;
111     }
112
113     public Object getValue() {
114         return value;
115     }
116
117     public void setValue(Object value) {
118         this.value = value;
119     }
120
121     @Override
122     public boolean equals(Object obj) {
123         if (this == obj) {
124             return true;
125         }
126         if (obj == null) {
127             return false;
128         }
129         if (getClass() != obj.getClass()) {
130             return false;
131         }
132         ItemVO other = (ItemVO) obj;
133         if (value == null) {
134             if (other.value != null) {
135                 return false;
136             }
137         } else if (!value.equals(other.value)) {
138             return false;
139         }
140         return Objects.equals(time, other.time);
141     }
142
143     @Override
144     public String toString() {
145         return new StringBuilder("ItemVO [tableName=").append(tableName).append(", newTableName=").append(newTableName)
146                 .append(", dbType=").append(dbType).append(", javaType=").append(javaType).append(", time=")
147                 .append(time).append(", value=").append(value).append("]").toString();
148     }
149 }