]> git.basschouten.com Git - openhab-addons.git/blob
0fe0c58c43bb42a2355d513575523433d34aedf8
[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 org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * Represents an INFORMATON_SCHEMA.COLUMNS table row.
20  *
21  * MySQL returns type as column_type
22  *
23  * PostgreSQL returns "data_type" (e.g. "character varying") and "udt_name" as a type alias (e.g. "varchar")
24  * these should be aliased as the matching snake_case version of the attributes in this class. i.e.:
25  * SELECT column_name, data_type as column_type, udt_name as column_type_alias FROM information_schema.columns
26  *
27  * @author Jacob Laursen - Initial contribution
28  */
29 @NonNullByDefault
30 public class Column {
31
32     private @Nullable String columnName;
33     private boolean isNullable;
34     private @Nullable String columnType;
35     private @Nullable String columnTypeAlias;
36
37     public String getColumnName() {
38         String columnName = this.columnName;
39         return columnName != null ? columnName : "";
40     }
41
42     public String getColumnType() {
43         String columnType = this.columnType;
44         return columnType != null ? columnType : "";
45     }
46
47     public String getColumnTypeAlias() {
48         String columnTypeAlias = this.columnTypeAlias;
49         return columnTypeAlias != null ? columnTypeAlias : "";
50     }
51
52     public boolean getIsNullable() {
53         return isNullable;
54     }
55
56     public void setColumnName(String columnName) {
57         this.columnName = columnName;
58     }
59
60     public void setColumnType(String columnType) {
61         this.columnType = columnType;
62     }
63
64     public void setColumnTypeAlias(String columnTypeAlias) {
65         this.columnTypeAlias = columnTypeAlias;
66     }
67
68     public void setIsNullable(boolean isNullable) {
69         this.isNullable = isNullable;
70     }
71 }