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.newsletter;
029
030/**
031 * Content for newsletters.<p>
032 */
033public class CmsNewsletterContent implements I_CmsNewsletterContent {
034
035    /** The output channel for this content. */
036    String m_channel;
037
038    /** The content String. */
039    String m_content;
040
041    /** The order of this content. */
042    int m_order;
043
044    /** The type of this content. */
045    CmsNewsletterContentType m_type;
046
047    /**
048     * Creates a new CmsNewsletterContent instance.<p>
049     *
050     * @param order the order of the newsletter content
051     * @param content the content
052     * @param type the newsletter contents' type
053     */
054    public CmsNewsletterContent(int order, String content, CmsNewsletterContentType type) {
055
056        m_order = order;
057        m_content = content;
058        m_type = type;
059        m_channel = "";
060    }
061
062    /**
063     *
064     * @see java.lang.Comparable#compareTo(java.lang.Object)
065     */
066    public int compareTo(I_CmsNewsletterContent o) {
067
068        return Integer.valueOf(m_order).compareTo(Integer.valueOf(((CmsNewsletterContent)o).getOrder()));
069    }
070
071    /**
072     *
073     * @see java.lang.Object#equals(java.lang.Object)
074     */
075    @Override
076    public boolean equals(Object obj) {
077
078        if (!(obj instanceof CmsNewsletterContent)) {
079            return false;
080        }
081        CmsNewsletterContent newsletterContent = (CmsNewsletterContent)obj;
082        if (getOrder() != newsletterContent.getOrder()) {
083            return false;
084        }
085        if (!getContent().equals(newsletterContent.getContent())) {
086            return false;
087        }
088        if (!getChannel().equals(newsletterContent.getChannel())) {
089            return false;
090        }
091        if (!getType().equals(newsletterContent.getType())) {
092            return false;
093        }
094        return true;
095    }
096
097    /**
098     *
099     * @see java.lang.Object#hashCode()
100     */
101    @Override
102    public int hashCode() {
103
104        return m_channel.hashCode() + m_content.hashCode() + m_order + m_type.hashCode();
105    }
106
107    /**
108     * @see org.opencms.newsletter.I_CmsNewsletterContent#getChannel()
109     */
110    public String getChannel() {
111
112        return m_channel;
113    }
114
115    /**
116     * @see org.opencms.newsletter.I_CmsNewsletterContent#getContent()
117     */
118    public String getContent() {
119
120        return m_content;
121    }
122
123    /**
124     * @see org.opencms.newsletter.I_CmsNewsletterContent#getOrder()
125     */
126    public int getOrder() {
127
128        return m_order;
129    }
130
131    /**
132     * @see org.opencms.newsletter.I_CmsNewsletterContent#getType()
133     */
134    public CmsNewsletterContentType getType() {
135
136        return m_type;
137    }
138}