Java tutorial
/* * SpiderDB - Lightweight Database Schema Crawler * Copyright (c) 2010, Avdhesh yadav. * Contact: avdhesh.yadav@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.avdheshyadav.spiderdb.dbmodel; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.CompareToBuilder; /** * * @author Avdhesh Yadav * */ public class ColumnDataType implements Comparable<ColumnDataType> { private int type; private String typeName; private int columnSize; private int decimalDegits; private int numPrecRedix; private boolean autoIncrementable; /** * * @param type int * @param typeName String * @param columnSize int * @param decimalDegits int * @param numPrecRedix int * @param autoIncrementable boolean */ public ColumnDataType(int type, String typeName, int columnSize, int decimalDegits, int numPrecRedix, boolean autoIncrementable) { this.type = type; this.typeName = typeName; this.columnSize = columnSize; this.decimalDegits = decimalDegits; this.numPrecRedix = numPrecRedix; this.autoIncrementable = autoIncrementable; } /** * * @return int */ public int getType() { return type; } /** * * @return String */ public String getTypeName() { return typeName; } /** * * @return int */ public int getColumnSize() { return columnSize; } /** * * @return int */ public int getNumPrecRedix() { return numPrecRedix; } /** * * @return int */ public int getDecimalDegits() { return decimalDegits; } /** * * @return boolean */ public boolean isAutoIncrementable() { return autoIncrementable; } public int compareTo(final ColumnDataType other) { return new CompareToBuilder().append(type, other.type).append(typeName, other.typeName) .append(columnSize, other.columnSize).append(decimalDegits, other.decimalDegits) .append(numPrecRedix, other.numPrecRedix).append(autoIncrementable, other.autoIncrementable) .toComparison(); } @Override public boolean equals(final Object other) { if (this == other) return true; if (!(other instanceof ColumnDataType)) return false; ColumnDataType castOther = (ColumnDataType) other; return new EqualsBuilder().append(type, castOther.type).append(typeName, castOther.typeName) .append(columnSize, castOther.columnSize).append(decimalDegits, castOther.decimalDegits) .append(numPrecRedix, castOther.numPrecRedix).append(autoIncrementable, castOther.autoIncrementable) .isEquals(); } @Override public int hashCode() { return new HashCodeBuilder().append(type).append(typeName).append(columnSize).append(decimalDegits) .append(numPrecRedix).append(autoIncrementable).toHashCode(); } @Override public String toString() { return "ColumnDataType [type=" + type + ", typeName=" + typeName + ", columnSize=" + columnSize + ", decimalDegits=" + decimalDegits + ", numPrecRedix=" + numPrecRedix + ", autoIncrementable=" + autoIncrementable + "]"; } }