Add collaboration feature
[sdc.git] / openecomp-be / tools / zusammen-tools / src / main / java / org / openecomp / core / tools / model / ColumnDefinition.java
1 /**
2  * Copyright © 2016-2017 European Support Limited.
3  */
4 package org.openecomp.core.tools.model;
5
6 import com.datastax.driver.core.ColumnDefinitions.Definition;
7 import com.datastax.driver.core.DataType;
8
9 import java.util.Arrays;
10
11 public class ColumnDefinition {
12
13     private String keyspace;
14     private String table;
15     private String name;
16     private String type;
17
18     public ColumnDefinition() {
19     }
20
21     public ColumnDefinition(String keyspace, String table, String name, DataType type) {
22         this.keyspace = keyspace;
23         this.table = table;
24         this.name = name;
25         this.type = type.getName().toString();
26     }
27
28     public ColumnDefinition(Definition definition) {
29         this(definition.getKeyspace(), definition.getTable(), definition.getName(), definition.getType());
30     }
31
32     /**
33      * The name of the keyspace this column is part of.
34      *
35      * @return the name of the keyspace this column is part of.
36      */
37     public String getKeyspace() {
38         return keyspace;
39     }
40
41     /**
42      * Returns the name of the table this column is part of.
43      *
44      * @return the name of the table this column is part of.
45      */
46     public String getTable() {
47         return table;
48     }
49
50     /**
51      * Returns the name of the column.
52      *
53      * @return the name of the column.
54      */
55     public String getName() {
56         return name;
57     }
58
59     /**
60      * Returns the type of the column.
61      *
62      * @return the type of the column.
63      */
64     public String getType() {
65         return type;
66     }
67
68     @Override
69     public final int hashCode() {
70         return Arrays.hashCode(new Object[]{keyspace, table, name, type});
71     }
72
73     @Override
74     public final boolean equals(Object o) {
75         if (!(o instanceof ColumnDefinition))
76             return false;
77
78         ColumnDefinition other = (ColumnDefinition) o;
79         return keyspace.equals(other.keyspace)
80                 && table.equals(other.table)
81                 && name.equals(other.name)
82                 && type.equals(other.type);
83     }
84 }