1 /**
2 * Copyright 2005-2015 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.krad.data.platform;
17
18 import org.apache.commons.lang.StringUtils;
19
20 /**
21 * Contains database platform information, specifically the name and major version of the database.
22 *
23 * <p>The name of the database platform should be considered as case insensitive.</p>
24 *
25 * @author Kuali Rice Team (rice.collab@kuali.org)
26 */
27 public final class DatabasePlatformInfo {
28
29 private final String name;
30 private final int majorVersion;
31
32 /**
33 * Creates database platform information.
34 *
35 * @param name the name of the database.
36 * @param majorVersion the major version of the database.
37 */
38 public DatabasePlatformInfo(String name, int majorVersion) {
39 if (StringUtils.isBlank(name)) {
40 throw new IllegalArgumentException("Name cannot be null or blank");
41 }
42 this.name = name;
43 this.majorVersion = majorVersion;
44 }
45
46 /**
47 * Gets the name of the database.
48 *
49 * @return the name of the database.
50 */
51 public String getName() {
52 return name;
53 }
54
55 /**
56 * Gets the major version of the database.
57 *
58 * @return the major version of the database.
59 */
60 public int getMajorVersion() {
61 return majorVersion;
62 }
63
64 /**
65 * {@inheritDoc}
66 */
67 @Override
68 public boolean equals(Object object) {
69 if (this == object) {
70 return true;
71 }
72 if (!(object instanceof DatabasePlatformInfo)) {
73 return false;
74 }
75
76 final DatabasePlatformInfo that = (DatabasePlatformInfo) object;
77
78 if (!name.equals(that.name)) {
79 return false;
80 }
81 if (majorVersion != that.majorVersion) {
82 return false;
83 }
84
85 return true;
86 }
87
88 /**
89 * {@inheritDoc}
90 */
91 @Override
92 public int hashCode() {
93 int result = name.hashCode();
94 result = 31 * result + majorVersion;
95 return result;
96 }
97
98 /**
99 * {@inheritDoc}
100 */
101 @Override
102 public String toString() {
103 return "DatabasePlatformInfo{" +
104 "name='" + name + '\'' +
105 ", majorVersion=" + majorVersion +
106 '}';
107 }
108 }