001package com.hfg.sql.jdbc; 002 003 004import com.hfg.util.CompareUtil; 005 006//------------------------------------------------------------------------------ 007/** 008 * Simple database schema container. 009 * @author J. Alex Taylor, hairyfatguy.com 010 */ 011//------------------------------------------------------------------------------ 012// com.hfg Library 013// 014// This library is free software; you can redistribute it and/or 015// modify it under the terms of the GNU Lesser General Public 016// License as published by the Free Software Foundation; either 017// version 2.1 of the License, or (at your option) any later version. 018// 019// This library is distributed in the hope that it will be useful, 020// but WITHOUT ANY WARRANTY; without even the implied warranty of 021// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 022// Lesser General Public License for more details. 023// 024// You should have received a copy of the GNU Lesser General Public 025// License along with this library; if not, write to the Free Software 026// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 027// 028// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 029// jataylor@hairyfatguy.com 030//------------------------------------------------------------------------------ 031 032public class Schema implements Comparable<Schema> 033{ 034 private String mName; 035 036 //########################################################################### 037 // CONSTRUCTORS 038 //########################################################################### 039 040 //-------------------------------------------------------------------------- 041 public Schema(String inName) 042 { 043 mName = inName; 044 } 045 046 //########################################################################### 047 // PUBLIC METHODS 048 //########################################################################### 049 050 //-------------------------------------------------------------------------- 051 public String name() 052 { 053 return mName; 054 } 055 056 //-------------------------------------------------------------------------- 057 @Override 058 public String toString() 059 { 060 return name(); 061 } 062 063 //-------------------------------------------------------------------------- 064 public int compareTo(Schema inObj2) 065 { 066 int result = -1; 067 if (inObj2 != null) 068 { 069 result = CompareUtil.compare(name(), inObj2.name()); 070 } 071 072 return result; 073 } 074 075 //-------------------------------------------------------------------------- 076 @Override 077 public boolean equals(Object inObj2) 078 { 079 boolean result = false; 080 if (inObj2 instanceof Schema) 081 { 082 Schema schema2 = (Schema) inObj2; 083 result = (0 == compareTo(schema2)); 084 } 085 086 return result; 087 } 088 089 //-------------------------------------------------------------------------- 090 @Override 091 public int hashCode() 092 { 093 return name().hashCode(); 094 } 095}