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.workplace;
029
030/**
031 * Contains the data of a single workplace view.<p>
032 *
033 * @since 6.0.0
034 */
035public class CmsWorkplaceView implements Comparable<CmsWorkplaceView> {
036
037    /** The localization key of this view. */
038    private String m_key;
039
040    /** The sort order of the view. */
041    private Float m_order;
042
043    /** The URI of the OpenCms VFS resource (folder) of the view. */
044    private String m_uri;
045
046    /**
047     * Creates a new workplace view.<p>
048     *
049     * @param key the localization key for the display name of the view
050     * @param uri of the view page in the OpenCms VFS
051     * @param order the sort order of the view
052     */
053    public CmsWorkplaceView(String key, String uri, Float order) {
054
055        m_key = key;
056        m_uri = uri;
057        m_order = order;
058    }
059
060    /**
061     * @see java.lang.Comparable#compareTo(java.lang.Object)
062     */
063    public int compareTo(CmsWorkplaceView obj) {
064
065        if (obj == this) {
066            return 0;
067        }
068        return m_order.compareTo(obj.getOrder());
069    }
070
071    /**
072     * @see java.lang.Object#equals(java.lang.Object)
073     */
074    @Override
075    public boolean equals(Object obj) {
076
077        if (obj == this) {
078            return true;
079        }
080        if (obj instanceof CmsWorkplaceView) {
081            return ((CmsWorkplaceView)obj).m_uri.equals(m_uri);
082        }
083        return false;
084    }
085
086    /**
087     * Returns the localization key for the display name of this view .<p>
088     *
089     * @return the localization key
090     */
091    public String getKey() {
092
093        return m_key;
094    }
095
096    /**
097     * Returns the sort order of this view.<p>
098     *
099     * @return the sort order of this view
100     */
101    public Float getOrder() {
102
103        return m_order;
104    }
105
106    /**
107     * Returns the OpenCms VFS uri of this view.<p>
108     *
109     * @return the uri
110     */
111    public String getUri() {
112
113        return m_uri;
114    }
115
116    /**
117     * @see java.lang.Object#hashCode()
118     */
119    @Override
120    public int hashCode() {
121
122        return getUri().hashCode();
123    }
124
125}