001/* 002 * HA-JDBC: High-Availability JDBC 003 * Copyright (c) 2004-2007 Paul Ferraro 004 * 005 * This library is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Lesser General Public License as published by the 007 * Free Software Foundation; either version 2.1 of the License, or (at your 008 * option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, but WITHOUT 011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 013 * for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public License 016 * along with this library; if not, write to the Free Software Foundation, 017 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 018 * 019 * Contact: ferraro@users.sourceforge.net 020 */ 021package net.sf.hajdbc.cache; 022 023import java.util.LinkedList; 024import java.util.List; 025 026import net.sf.hajdbc.UniqueConstraint; 027 028/** 029 * @author Paul Ferraro 030 * 031 */ 032public class UniqueConstraintImpl implements UniqueConstraint 033{ 034 private String name; 035 private String table; 036 private List<String> columnList = new LinkedList<String>(); 037 038 /** 039 * Constructs a new UniqueConstraint. 040 * @param name the name of this constraint 041 * @param table a schema qualified table name 042 */ 043 public UniqueConstraintImpl(String name, String table) 044 { 045 this.name = name; 046 this.table = table; 047 } 048 049 /** 050 * @see net.sf.hajdbc.UniqueConstraint#getColumnList() 051 */ 052 @Override 053 public List<String> getColumnList() 054 { 055 return this.columnList; 056 } 057 058 /** 059 * @see net.sf.hajdbc.UniqueConstraint#getName() 060 */ 061 @Override 062 public String getName() 063 { 064 return this.name; 065 } 066 067 /** 068 * @see net.sf.hajdbc.UniqueConstraint#getTable() 069 */ 070 @Override 071 public String getTable() 072 { 073 return this.table; 074 } 075 076 /** 077 * @see java.lang.Object#equals(java.lang.Object) 078 */ 079 @Override 080 public boolean equals(Object object) 081 { 082 if ((object == null) || !(object instanceof UniqueConstraint)) return false; 083 084 String name = ((UniqueConstraint) object).getName(); 085 086 return (name != null) && name.equals(this.name); 087 } 088 089 /** 090 * @see java.lang.Object#hashCode() 091 */ 092 @Override 093 public int hashCode() 094 { 095 return this.name.hashCode(); 096 } 097 098 /** 099 * @see java.lang.Comparable#compareTo(java.lang.Object) 100 */ 101 @Override 102 public int compareTo(UniqueConstraint constraint) 103 { 104 return this.name.compareTo(constraint.getName()); 105 } 106}