Improved unit tests for AveragingProgressTracker class
[controller.git] / opendaylight / md-sal / sal-dom-xsql / src / main / java / org / opendaylight / controller / md / sal / dom / xsql / XSQLColumn.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.md.sal.dom.xsql;
10
11 import java.io.Serializable;
12
13 /**
14  * To be removed in Nitrogen
15  */
16 @Deprecated
17 public class XSQLColumn implements Serializable, Comparable<Object> {
18     private static final long serialVersionUID = 4854919735031714751L;
19
20     private String name = null;
21     private String tableName = null;
22     private int charWidth = -1;
23     private Class<?> type = null;
24     private transient Object bluePrintNode = null;
25     private String origName = null;
26     private String origTableName = null;
27
28     public XSQLColumn(Object odlNode, String _tableName, Object _bluePrintNode) {
29         this.name = XSQLODLUtils.getNodeNameFromDSN(odlNode);
30         this.tableName = _tableName;
31         this.bluePrintNode = _bluePrintNode;
32         this.type = XSQLODLUtils.getTypeForODLColumn(odlNode);
33     }
34
35     public XSQLColumn(String _name, String _tableName,String _origName, String _origTableName){
36         this.name = _name;
37         this.tableName = _tableName;
38         this.origName = _origName;
39         this.origTableName = _origTableName;
40     }
41
42     public String getName() {
43         return name;
44     }
45
46     public String getTableName() {
47         return tableName;
48     }
49
50     public void setCharWidth(int i) {
51         if (this.charWidth < i) {
52             this.charWidth = i;
53         }
54     }
55
56     public int getCharWidth() {
57         return this.charWidth;
58     }
59
60     @Override
61     public int hashCode() {
62         return this.name.hashCode() + this.tableName.hashCode();
63     }
64
65     @Override
66     public boolean equals(Object obj) {
67         if (!(obj instanceof XSQLColumn)) {
68             return false;
69         }
70         XSQLColumn other = (XSQLColumn) obj;
71         return tableName.equals(other.tableName) && name.equals(other.name);
72     }
73
74     public Object getBluePrintNode() {
75         return this.bluePrintNode;
76     }
77
78     @Override
79     public String toString() {
80         return tableName + "." + name;
81     }
82
83     @Override
84     public int compareTo(Object o) {
85         return this.toString().compareTo(o.toString());
86     }
87
88     public Object getResultSetValue(Object obj){
89         if(this.type.equals(String.class)){
90             return obj.toString();
91         }else
92         if(this.type.equals(int.class)){
93             return Integer.parseInt(obj.toString());
94         }else
95         if(this.type.equals(long.class)){
96             return Long.parseLong(obj.toString());
97         }else
98         if(this.type.equals(byte.class)){
99             return Byte.parseByte(obj.toString());
100         }
101         return null;
102     }
103 }