001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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    /**
022     * @author     Brian Wing Shun Chan
023     * @deprecated As of 7.0.0, replaced by {@link com.liferay.shopping.util.State)}
024     */
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    }