001
014
015 package com.liferay.util;
016
017 import com.liferay.portal.kernel.util.HashCode;
018 import com.liferay.portal.kernel.util.HashCodeFactoryUtil;
019
020
023 public class State {
024
025 public State(String id, String name) {
026 _id = id;
027 _name = name;
028 }
029
030 public int compareTo(Object obj) {
031 State state = (State)obj;
032
033 if (getId() != null && state.getId() != null) {
034 return getId().toLowerCase().compareTo(state.getId().toLowerCase());
035 }
036 else if (getName() != null && state.getName() != null) {
037 return getName().toLowerCase().compareTo(
038 state.getName().toLowerCase());
039 }
040 else {
041 return -1;
042 }
043 }
044
045 @Override
046 public boolean equals(Object obj) {
047 State state = (State)obj;
048
049 if ((getId() != null) && (state.getId() != null)) {
050 return getId().equalsIgnoreCase(state.getId());
051 }
052 else if ((getName() != null) && (state.getName() != null)) {
053 return getName().equalsIgnoreCase(state.getName());
054 }
055 else {
056 return false;
057 }
058 }
059
060 public String getId() {
061 return _id;
062 }
063
064 public String getName() {
065 return _name;
066 }
067
068 @Override
069 public int hashCode() {
070 HashCode hashCode = HashCodeFactoryUtil.getHashCode();
071
072 hashCode.append(_id);
073 hashCode.append(_name);
074
075 return hashCode.toHashCode();
076 }
077
078 private String _id;
079 private String _name;
080
081 }