| 1 |
/* |
| 2 |
* Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, |
| 3 |
* and the EPL 1.0 (https://h2database.com/html/license.html). |
| 4 |
* Initial Developer: H2 Group |
| 5 |
*/ |
| 6 |
package org.h2.util; |
| 7 |
|
| 8 |
/** |
| 9 |
* Metadata of a column. |
| 10 |
* |
| 11 |
* <p> |
| 12 |
* Notice: {@linkplain #equals(Object)} and {@linkplain #hashCode()} use only |
| 13 |
* {@linkplain #name} field. |
| 14 |
* </p> |
| 15 |
*/ |
| 16 |
public final class SimpleColumnInfo { |
| 17 |
/** |
| 18 |
* Name of the column. |
| 19 |
*/ |
| 20 |
public final String name; |
| 21 |
|
| 22 |
/** |
| 23 |
* Type of the column, see {@link java.sql.Types}. |
| 24 |
*/ |
| 25 |
public final int type; |
| 26 |
|
| 27 |
/** |
| 28 |
* Type name of the column. |
| 29 |
*/ |
| 30 |
public final String typeName; |
| 31 |
|
| 32 |
/** |
| 33 |
* Precision of the column |
| 34 |
*/ |
| 35 |
public final int precision; |
| 36 |
|
| 37 |
/** |
| 38 |
* Scale of the column. |
| 39 |
*/ |
| 40 |
public final int scale; |
| 41 |
|
| 42 |
/** |
| 43 |
* Creates metadata. |
| 44 |
* |
| 45 |
* @param name |
| 46 |
* name of the column |
| 47 |
* @param type |
| 48 |
* type of the column, see {@link java.sql.Types} |
| 49 |
* @param typeName |
| 50 |
* type name of the column |
| 51 |
* @param precision |
| 52 |
* precision of the column |
| 53 |
* @param scale |
| 54 |
* scale of the column |
| 55 |
*/ |
| 56 |
public SimpleColumnInfo(String name, int type, String typeName, int precision, int scale) { |
| 57 |
this.name = name; |
| 58 |
this.type = type; |
| 59 |
this.typeName = typeName; |
| 60 |
this.precision = precision; |
| 61 |
this.scale = scale; |
| 62 |
} |
| 63 |
|
| 64 |
@Override |
| 65 |
public boolean equals(Object obj) { |
| 66 |
if (this == obj) { |
| 67 |
return true; |
| 68 |
} |
| 69 |
if (obj == null || getClass() != obj.getClass()) { |
| 70 |
return false; |
| 71 |
} |
| 72 |
SimpleColumnInfo other = (SimpleColumnInfo) obj; |
| 73 |
return name.equals(other.name); |
| 74 |
} |
| 75 |
|
| 76 |
@Override |
| 77 |
public int hashCode() { |
| 78 |
return name.hashCode(); |
| 79 |
} |
| 80 |
} |