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 import com.liferay.portal.kernel.util.StringUtil;
020
021
025 @Deprecated
026 public class State {
027
028 public State(String id, String name) {
029 _id = id;
030 _name = name;
031 }
032
033 public int compareTo(Object obj) {
034 State state = (State)obj;
035
036 if ((getId() != null) && (state.getId() != null)) {
037 return StringUtil.toLowerCase(getId()).compareTo(
038 StringUtil.toLowerCase(state.getId()));
039 }
040 else if ((getName() != null) && (state.getName() != null)) {
041 return StringUtil.toLowerCase(getName()).compareTo(
042 StringUtil.toLowerCase(state.getName()));
043 }
044 else {
045 return -1;
046 }
047 }
048
049 @Override
050 public boolean equals(Object obj) {
051 if (this == obj) {
052 return true;
053 }
054
055 if (!(obj instanceof State)) {
056 return false;
057 }
058
059 State state = (State)obj;
060
061 if ((getId() != null) && (state.getId() != null)) {
062 return StringUtil.equalsIgnoreCase(getId(), state.getId());
063 }
064 else if ((getName() != null) && (state.getName() != null)) {
065 return StringUtil.equalsIgnoreCase(getName(), state.getName());
066 }
067 else {
068 return false;
069 }
070 }
071
072 public String getId() {
073 return _id;
074 }
075
076 public String getName() {
077 return _name;
078 }
079
080 @Override
081 public int hashCode() {
082 HashCode hashCode = HashCodeFactoryUtil.getHashCode();
083
084 hashCode.append(_id);
085 hashCode.append(_name);
086
087 return hashCode.toHashCode();
088 }
089
090 private final String _id;
091 private final String _name;
092
093 }