1
14
15 package com.liferay.util;
16
17 import com.liferay.portal.kernel.util.HashCode;
18 import com.liferay.portal.kernel.util.HashCodeFactoryUtil;
19
20
25 public class State {
26
27 public State(String id, String name) {
28 _id = id;
29 _name = name;
30 }
31
32 public String getId() {
33 return _id;
34 }
35
36 public String getName() {
37 return _name;
38 }
39
40 public int compareTo(Object obj) {
41 State state = (State)obj;
42
43 if (getId() != null && state.getId() != null) {
44 return getId().toLowerCase().compareTo(state.getId().toLowerCase());
45 }
46 else if (getName() != null && state.getName() != null) {
47 return getName().toLowerCase().compareTo(
48 state.getName().toLowerCase());
49 }
50 else {
51 return -1;
52 }
53 }
54
55 public boolean equals(Object obj) {
56 State state = (State)obj;
57
58 if ((getId() != null) && (state.getId() != null)) {
59 return getId().equalsIgnoreCase(state.getId());
60 }
61 else if ((getName() != null) && (state.getName() != null)) {
62 return getName().equalsIgnoreCase(state.getName());
63 }
64 else {
65 return false;
66 }
67 }
68
69 public int hashCode() {
70 HashCode hashCode = HashCodeFactoryUtil.getHashCode();
71
72 hashCode.append(_id);
73 hashCode.append(_name);
74
75 return hashCode.toHashCode();
76 }
77
78 private String _id;
79 private String _name;
80
81 }