State.java |
1 /** 2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved. 3 * 4 * 5 * 6 * 7 * The contents of this file are subject to the terms of the Liferay Enterprise 8 * Subscription License ("License"). You may not use this file except in 9 * compliance with the License. You can obtain a copy of the License by 10 * contacting Liferay, Inc. See the License for the specific language governing 11 * permissions and limitations under the License, including but not limited to 12 * distribution rights of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 * SOFTWARE. 21 */ 22 23 package com.liferay.util; 24 25 /** 26 * <a href="State.java.html"><b><i>View Source</i></b></a> 27 * 28 * @author Brian Wing Shun Chan 29 */ 30 public class State { 31 32 public State(String id, String name) { 33 _id = id; 34 _name = name; 35 } 36 37 public String getId() { 38 return _id; 39 } 40 41 public String getName() { 42 return _name; 43 } 44 45 public int compareTo(Object obj) { 46 State state = (State)obj; 47 48 if (getId() != null && state.getId() != null) { 49 return getId().toLowerCase().compareTo(state.getId().toLowerCase()); 50 } 51 else if (getName() != null && state.getName() != null) { 52 return getName().toLowerCase().compareTo( 53 state.getName().toLowerCase()); 54 } 55 else { 56 return -1; 57 } 58 } 59 60 public boolean equals(Object obj) { 61 State state = (State)obj; 62 63 if (getId() != null && state.getId() != null) { 64 return getId().equalsIgnoreCase(state.getId()); 65 } 66 else if (getName() != null && state.getName() != null) { 67 return getName().equalsIgnoreCase(state.getName()); 68 } 69 else { 70 return false; 71 } 72 } 73 74 private String _id; 75 private String _name; 76 77 }