001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.util;
029
030import java.io.Serializable;
031
032/**
033 * Base class for all string mode enumeration classes.<p>
034 *
035 * Like:<br>
036 * <ul>
037 *   <li>{@link org.opencms.db.CmsUserSettings.CmsSearchResultStyle}
038 * </ul>
039 *
040 * @since 6.5.5
041 */
042public abstract class A_CmsModeStringEnumeration implements Serializable {
043
044    /** Serialization id. */
045    private static final long serialVersionUID = 6884841215348447781L;
046
047    /** The internal mode descriptor. */
048    private final String m_mode;
049
050    /**
051     * Default constructor.<p>
052     *
053     * @param mode the internal mode descriptor
054     */
055    protected A_CmsModeStringEnumeration(String mode) {
056
057        m_mode = mode;
058    }
059
060    /**
061     * @see java.lang.Object#equals(java.lang.Object)
062     */
063    @Override
064    public boolean equals(Object obj) {
065
066        if (obj == this) {
067            return true;
068        }
069        if (obj instanceof A_CmsModeStringEnumeration) {
070            if (obj.getClass().equals(this.getClass())) {
071                A_CmsModeStringEnumeration eObj = (A_CmsModeStringEnumeration)obj;
072                return eObj.getMode().equals(m_mode);
073            }
074        }
075        return false;
076    }
077
078    /**
079     * Returns the mode.<p>
080     *
081     * @return the mode
082     */
083    public String getMode() {
084
085        return m_mode;
086    }
087
088    /**
089     * @see java.lang.Object#hashCode()
090     */
091    @Override
092    public int hashCode() {
093
094        return m_mode.hashCode();
095    }
096
097    /**
098     * @see java.lang.Object#toString()
099     */
100    @Override
101    public String toString() {
102
103        return m_mode;
104    }
105}