Added oparent to sdc main
[sdc.git] / openecomp-be / tools / zusammen-tools / src / main / java / org / openecomp / core / tools / model / ColumnDefinition.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 AT&T European Support Limited. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.openecomp.core.tools.model;
21
22 import com.datastax.driver.core.ColumnDefinitions.Definition;
23 import com.datastax.driver.core.DataType;
24
25 import java.util.Arrays;
26
27 public class ColumnDefinition {
28
29     private String keyspace;
30     private String table;
31     private String name;
32     private String type;
33
34     public ColumnDefinition() {
35     }
36
37     public ColumnDefinition(String keyspace, String table, String name, DataType type) {
38         this.keyspace = keyspace;
39         this.table = table;
40         this.name = name;
41         this.type = type.getName().toString();
42     }
43
44     public ColumnDefinition(Definition definition) {
45         this(definition.getKeyspace(), definition.getTable(), definition.getName(), definition.getType());
46     }
47
48     /**
49      * The name of the keyspace this column is part of.
50      *
51      * @return the name of the keyspace this column is part of.
52      */
53     public String getKeyspace() {
54         return keyspace;
55     }
56
57     /**
58      * Returns the name of the table this column is part of.
59      *
60      * @return the name of the table this column is part of.
61      */
62     public String getTable() {
63         return table;
64     }
65
66     /**
67      * Returns the name of the column.
68      *
69      * @return the name of the column.
70      */
71     public String getName() {
72         return name;
73     }
74
75     /**
76      * Returns the type of the column.
77      *
78      * @return the type of the column.
79      */
80     public String getType() {
81         return type;
82     }
83
84     @Override
85     public final int hashCode() {
86         return Arrays.hashCode(new Object[]{keyspace, table, name, type});
87     }
88
89     @Override
90     public final boolean equals(Object o) {
91         if (!(o instanceof ColumnDefinition))
92             return false;
93
94         ColumnDefinition other = (ColumnDefinition) o;
95         return keyspace.equals(other.keyspace)
96                 && table.equals(other.table)
97                 && name.equals(other.name)
98                 && type.equals(other.type);
99     }
100 }