001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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            @Override
038            public boolean equals(Object obj) {
039                    if (obj == null) {
040                            return false;
041                    }
042    
043                    if (!(obj instanceof PortalCacheClusterEvent)) {
044                            return false;
045                    }
046    
047                    PortalCacheClusterEvent portalCacheClusterEvent =
048                            (PortalCacheClusterEvent)obj;
049    
050                    if (Validator.equals(_cacheName, portalCacheClusterEvent._cacheName) &&
051                            Validator.equals(
052                                    _elementKey, portalCacheClusterEvent._elementKey) &&
053                            Validator.equals(
054                                    _portalCacheClusterEventType,
055                                    portalCacheClusterEvent._portalCacheClusterEventType)) {
056    
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            public String getCacheName() {
064                    return _cacheName;
065            }
066    
067            public Serializable getElementKey() {
068                    return _elementKey;
069            }
070    
071            public PortalCacheClusterEventType getEventType() {
072                    return _portalCacheClusterEventType;
073            }
074    
075            @Override
076            public int hashCode() {
077                    return toString().hashCode();
078            }
079    
080            @Override
081            public String toString() {
082                    StringBundler sb = new StringBundler(5);
083    
084                    sb.append(_cacheName);
085                    sb.append(StringPool.COLON);
086                    sb.append(_elementKey.toString());
087                    sb.append(StringPool.COLON);
088                    sb.append(_portalCacheClusterEventType.toString());
089    
090                    return sb.toString();
091            }
092    
093            private String _cacheName;
094            private Serializable _elementKey;
095            private PortalCacheClusterEventType _portalCacheClusterEventType;
096    
097    }