01: /*
02: * HA-JDBC: High-Availability JDBC
03: * Copyright (c) 2004-2007 Paul Ferraro
04: *
05: * This library is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU Lesser General Public License as published by the
07: * Free Software Foundation; either version 2.1 of the License, or (at your
08: * option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful, but WITHOUT
11: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13: * for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public License
16: * along with this library; if not, write to the Free Software Foundation,
17: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: *
19: * Contact: ferraro@users.sourceforge.net
20: */
21: package net.sf.hajdbc.cache;
22:
23: import java.util.LinkedList;
24: import java.util.List;
25:
26: import net.sf.hajdbc.UniqueConstraint;
27:
28: /**
29: * @author Paul Ferraro
30: *
31: */
32: public class UniqueConstraintImpl implements UniqueConstraint {
33: private String name;
34: private String table;
35: private List<String> columnList = new LinkedList<String>();
36:
37: /**
38: * Constructs a new UniqueConstraint.
39: * @param name the name of this constraint
40: * @param table a schema qualified table name
41: */
42: public UniqueConstraintImpl(String name, String table) {
43: this .name = name;
44: this .table = table;
45: }
46:
47: /**
48: * @see net.sf.hajdbc.UniqueConstraint#getColumnList()
49: */
50: @Override
51: public List<String> getColumnList() {
52: return this .columnList;
53: }
54:
55: /**
56: * @see net.sf.hajdbc.UniqueConstraint#getName()
57: */
58: @Override
59: public String getName() {
60: return this .name;
61: }
62:
63: /**
64: * @see net.sf.hajdbc.UniqueConstraint#getTable()
65: */
66: @Override
67: public String getTable() {
68: return this .table;
69: }
70:
71: /**
72: * @see java.lang.Object#equals(java.lang.Object)
73: */
74: @Override
75: public boolean equals(Object object) {
76: if ((object == null) || !(object instanceof UniqueConstraint))
77: return false;
78:
79: String name = ((UniqueConstraint) object).getName();
80:
81: return (name != null) && name.equals(this .name);
82: }
83:
84: /**
85: * @see java.lang.Object#hashCode()
86: */
87: @Override
88: public int hashCode() {
89: return this .name.hashCode();
90: }
91:
92: /**
93: * @see java.lang.Comparable#compareTo(java.lang.Object)
94: */
95: @Override
96: public int compareTo(UniqueConstraint constraint) {
97: return this.name.compareTo(constraint.getName());
98: }
99: }
|