001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.cache.cluster;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.kernel.util.Validator;
020    
021    import java.io.Serializable;
022    
023    /**
024     * @author Shuyang Zhou
025     */
026    public class PortalCacheClusterEvent implements Serializable {
027    
028            public PortalCacheClusterEvent(
029                    String cacheName, Serializable elementKey,
030                    PortalCacheClusterEventType portalCacheClusterEventType) {
031    
032                    _cacheName = cacheName;
033                    _elementKey = elementKey;
034                    _portalCacheClusterEventType = portalCacheClusterEventType;
035            }
036    
037            public boolean equals(Object obj) {
038                    if (obj == null) {
039                            return false;
040                    }
041    
042                    if (!(obj instanceof PortalCacheClusterEvent)) {
043                            return false;
044                    }
045    
046                    PortalCacheClusterEvent portalCacheClusterEvent =
047                            (PortalCacheClusterEvent)obj;
048    
049                    if (Validator.equals(_cacheName, portalCacheClusterEvent._cacheName) &&
050                            Validator.equals(
051                                    _elementKey, portalCacheClusterEvent._elementKey) &&
052                            Validator.equals(
053                                    _portalCacheClusterEventType,
054                                    portalCacheClusterEvent._portalCacheClusterEventType)) {
055    
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062            public String getCacheName() {
063                    return _cacheName;
064            }
065    
066            public Serializable getElementKey() {
067                    return _elementKey;
068            }
069    
070            public PortalCacheClusterEventType getEventType() {
071                    return _portalCacheClusterEventType;
072            }
073    
074            public int hashCode() {
075                    return toString().hashCode();
076            }
077    
078            public String toString() {
079                    StringBundler sb = new StringBundler(5);
080    
081                    sb.append(_cacheName);
082                    sb.append(StringPool.COLON);
083                    sb.append(_elementKey.toString());
084                    sb.append(StringPool.COLON);
085                    sb.append(_portalCacheClusterEventType.toString());
086    
087                    return sb.toString();
088            }
089    
090            private String _cacheName;
091            private Serializable _elementKey;
092            private PortalCacheClusterEventType _portalCacheClusterEventType;
093    
094    }