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, 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.notification; 029 030import org.opencms.util.CmsUUID; 031 032import java.io.Serializable; 033 034/** 035 * Objects of this class are serialized in the additional infos of a user to store, which resources were 036 * already confirmed by the user. 037 * This class is the counterpart to <code>{@link org.opencms.notification.CmsExtendedNotificationCause}</code>, to be used 038 * for serialization in the AdditionalInfos of a <code>{@link org.opencms.file.CmsUser}</code>, and therefore only 039 * contains the essential information 040 * <p> 041 * 042 */ 043public class CmsNotificationCause implements Serializable { 044 045 /** Serial version UID required for safe serialization. */ 046 private static final long serialVersionUID = 257325098377830418L; 047 048 /** The reason that the resource occures in the notification. */ 049 private int m_cause; 050 051 /** The resource. */ 052 private CmsUUID m_resourceId; 053 054 /** 055 * Creates a new CmsNotificationResourceInfo.<p> 056 * 057 * @param resource the specific resource 058 * @param cause that the resource occures in the notification 059 */ 060 public CmsNotificationCause(CmsUUID resource, int cause) { 061 062 m_resourceId = resource; 063 m_cause = cause; 064 } 065 066 /** 067 * Returns true if the Object equals to the corresponding CmsNotificationCause, that means a notification cause 068 * with the same resource and cause. 069 * 070 * @return true if the resource info is equal to a notification cause or resource info with the same resource and cause 071 * 072 * @param o the object to check for equality 073 * 074 * @see org.opencms.notification.CmsExtendedNotificationCause#equals(java.lang.Object) 075 */ 076 @Override 077 public boolean equals(Object o) { 078 079 if (!((o instanceof CmsExtendedNotificationCause) || (o instanceof CmsNotificationCause))) { 080 return false; 081 } 082 return hashCode() == o.hashCode(); 083 } 084 085 /** 086 * Returns the cause.<p> 087 * 088 * @return the cause 089 */ 090 public int getCause() { 091 092 return m_cause; 093 } 094 095 /** 096 * Returns the resource.<p> 097 * 098 * @return the resource 099 */ 100 public CmsUUID getResourceId() { 101 102 return m_resourceId; 103 } 104 105 /** 106 * 107 * @see java.lang.Object#hashCode() 108 */ 109 @Override 110 public int hashCode() { 111 112 return m_cause + m_resourceId.hashCode(); 113 } 114 115 /** 116 * Sets the cause.<p> 117 * 118 * @param cause the cause to set 119 */ 120 public void setCause(int cause) { 121 122 m_cause = cause; 123 } 124 125 /** 126 * Sets the resource.<p> 127 * 128 * @param resourceId the resource to set 129 */ 130 public void setResourceId(CmsUUID resourceId) { 131 132 m_resourceId = resourceId; 133 } 134}