001/** 002 * Copyright 2005-2015 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.data.platform; 017 018import org.apache.commons.lang.StringUtils; 019 020/** 021 * Contains database platform information, specifically the name and major version of the database. 022 * 023 * <p>The name of the database platform should be considered as case insensitive.</p> 024 * 025 * @author Kuali Rice Team (rice.collab@kuali.org) 026 */ 027public final class DatabasePlatformInfo { 028 029 private final String name; 030 private final int majorVersion; 031 032 /** 033 * Creates database platform information. 034 * 035 * @param name the name of the database. 036 * @param majorVersion the major version of the database. 037 */ 038 public DatabasePlatformInfo(String name, int majorVersion) { 039 if (StringUtils.isBlank(name)) { 040 throw new IllegalArgumentException("Name cannot be null or blank"); 041 } 042 this.name = name; 043 this.majorVersion = majorVersion; 044 } 045 046 /** 047 * Gets the name of the database. 048 * 049 * @return the name of the database. 050 */ 051 public String getName() { 052 return name; 053 } 054 055 /** 056 * Gets the major version of the database. 057 * 058 * @return the major version of the database. 059 */ 060 public int getMajorVersion() { 061 return majorVersion; 062 } 063 064 /** 065 * {@inheritDoc} 066 */ 067 @Override 068 public boolean equals(Object object) { 069 if (this == object) { 070 return true; 071 } 072 if (!(object instanceof DatabasePlatformInfo)) { 073 return false; 074 } 075 076 final DatabasePlatformInfo that = (DatabasePlatformInfo) object; 077 078 if (!name.equals(that.name)) { 079 return false; 080 } 081 if (majorVersion != that.majorVersion) { 082 return false; 083 } 084 085 return true; 086 } 087 088 /** 089 * {@inheritDoc} 090 */ 091 @Override 092 public int hashCode() { 093 int result = name.hashCode(); 094 result = 31 * result + majorVersion; 095 return result; 096 } 097 098 /** 099 * {@inheritDoc} 100 */ 101 @Override 102 public String toString() { 103 return "DatabasePlatformInfo{" + 104 "name='" + name + '\'' + 105 ", majorVersion=" + majorVersion + 106 '}'; 107 } 108}