2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.persistence.jdbc.internal.dto;
15 import java.io.Serializable;
16 import java.util.Date;
17 import java.util.Objects;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * Represents the Item-data on the part of MyBatis/database.
26 * @author Helmut Lehmeyer - Initial contribution
28 public class ItemVO implements Serializable {
29 private final Logger logger = LoggerFactory.getLogger(ItemVO.class);
31 private static final long serialVersionUID = 1871441039821454890L;
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;
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;
51 public void setValueTypes(String dbType, Class<?> javaType) {
52 logger.debug("JDBC:ItemVO setValueTypes dbType={}; javaType={};", dbType, javaType);
54 this.javaType = javaType;
57 public String getTableName() {
61 public void setTableName(String tableName) {
62 this.tableName = tableName;
65 public @Nullable String getNewTableName() {
69 public void setNewTableName(String newTableName) {
70 this.newTableName = newTableName;
73 public String getDbType() {
77 public void setDbType(String dbType) {
81 public String getJdbcType() {
85 public void setJdbcType(String jdbcType) {
86 this.jdbcType = jdbcType;
89 public String getItemType() {
93 public void setItemType(String itemType) {
94 this.itemType = itemType;
97 public String getJavaType() {
98 return javaType.getName();
101 public void setJavaType(Class<?> javaType) {
102 this.javaType = javaType;
105 public Date getTime() {
109 public void setTime(Date time) {
113 public Object getValue() {
117 public void setValue(Object value) {
122 public boolean equals(Object obj) {
129 if (getClass() != obj.getClass()) {
132 ItemVO other = (ItemVO) obj;
134 if (other.value != null) {
137 } else if (!value.equals(other.value)) {
140 return Objects.equals(time, other.time);
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();