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 integer mode enumeration classes.<p>
034 *
035 * Like:<br>
036 * <ul>
037 *   <li>{@link org.opencms.file.CmsResource.CmsResourceCopyMode}
038 *   <li>{@link org.opencms.file.CmsResource.CmsResourceDeleteMode}
039 *   <li>{@link org.opencms.file.CmsResource.CmsResourceUndoMode}
040 * </ul>
041 *
042 * @since 6.5.3
043 */
044public abstract class A_CmsModeIntEnumeration implements Serializable {
045
046    /** Serialization id. */
047    private static final long serialVersionUID = -6652924582255509879L;
048
049    /** The internal mode descriptor. */
050    private final int m_mode;
051
052    /**
053     * Default constructor.<p>
054     *
055     * @param mode the internal mode descriptor
056     */
057    protected A_CmsModeIntEnumeration(int mode) {
058
059        m_mode = mode;
060    }
061
062    /**
063     * @see java.lang.Object#equals(java.lang.Object)
064     */
065    @Override
066    public boolean equals(Object obj) {
067
068        if (obj == this) {
069            return true;
070        }
071        if (obj instanceof A_CmsModeIntEnumeration) {
072            if (obj.getClass().equals(this.getClass())) {
073                A_CmsModeIntEnumeration eObj = (A_CmsModeIntEnumeration)obj;
074                return eObj.getMode() == m_mode;
075            }
076        }
077        return false;
078    }
079
080    /**
081     * Returns the mode.<p>
082     *
083     * @return the mode
084     */
085    public int getMode() {
086
087        return m_mode;
088    }
089
090    /**
091     * @see java.lang.Object#hashCode()
092     */
093    @Override
094    public int hashCode() {
095
096        return m_mode;
097    }
098
099    /**
100     * @see java.lang.Object#toString()
101     */
102    @Override
103    public String toString() {
104
105        return String.valueOf(m_mode);
106    }
107}