1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.cache.cluster;
16  
17  import com.liferay.portal.kernel.util.StringBundler;
18  import com.liferay.portal.kernel.util.StringPool;
19  import com.liferay.portal.kernel.util.Validator;
20  
21  import java.io.Serializable;
22  
23  /**
24   * <a href="PortalCacheClusterEvent.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Shuyang Zhou
27   */
28  public class PortalCacheClusterEvent implements Serializable {
29  
30      public PortalCacheClusterEvent(
31          String cacheName, Serializable elementKey,
32          PortalCacheClusterEventType portalCacheClusterEventType) {
33  
34          _cacheName = cacheName;
35          _elementKey = elementKey;
36          _portalCacheClusterEventType = portalCacheClusterEventType;
37      }
38  
39      public boolean equals(Object obj) {
40          if (obj == null) {
41              return false;
42          }
43  
44          if (!(obj instanceof PortalCacheClusterEvent)) {
45              return false;
46          }
47  
48          PortalCacheClusterEvent portalCacheClusterEvent =
49              (PortalCacheClusterEvent)obj;
50  
51          if (Validator.equals(_cacheName, portalCacheClusterEvent._cacheName) &&
52              Validator.equals(
53                  _elementKey, portalCacheClusterEvent._elementKey) &&
54              Validator.equals(
55                  _portalCacheClusterEventType,
56                  portalCacheClusterEvent._portalCacheClusterEventType)) {
57  
58              return true;
59          }
60  
61          return true;
62      }
63  
64      public String getCacheName() {
65          return _cacheName;
66      }
67  
68      public Serializable getElementKey() {
69          return _elementKey;
70      }
71  
72      public PortalCacheClusterEventType getEventType() {
73          return _portalCacheClusterEventType;
74      }
75  
76      public int hashCode() {
77          return toString().hashCode();
78      }
79  
80      public String toString() {
81          StringBundler sb = new StringBundler(5);
82  
83          sb.append(_cacheName);
84          sb.append(StringPool.COLON);
85          sb.append(_elementKey.toString());
86          sb.append(StringPool.COLON);
87          sb.append(_portalCacheClusterEventType.toString());
88  
89          return sb.toString();
90      }
91  
92      private String _cacheName;
93      private Serializable _elementKey;
94      private PortalCacheClusterEventType _portalCacheClusterEventType;
95  
96  }