001
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
026 public class PortalCacheClusterEvent implements Serializable {
027
028 public PortalCacheClusterEvent(
029 String cacheName, Serializable elementKey,
030 PortalCacheClusterEventType portalCacheClusterEventType) {
031
032 this(cacheName, elementKey, null, portalCacheClusterEventType);
033 }
034
035 public PortalCacheClusterEvent(
036 String cacheName, Serializable elementKey, Serializable elementValue,
037 PortalCacheClusterEventType portalCacheClusterEventType) {
038
039 _cacheName = cacheName;
040 _elementKey = elementKey;
041 _elementValue = elementValue;
042 _portalCacheClusterEventType = portalCacheClusterEventType;
043 }
044
045 @Override
046 public boolean equals(Object obj) {
047 if (this == obj) {
048 return true;
049 }
050
051 if (!(obj instanceof PortalCacheClusterEvent)) {
052 return false;
053 }
054
055 PortalCacheClusterEvent portalCacheClusterEvent =
056 (PortalCacheClusterEvent)obj;
057
058 if (Validator.equals(_cacheName, portalCacheClusterEvent._cacheName) &&
059 Validator.equals(
060 _elementKey, portalCacheClusterEvent._elementKey) &&
061 Validator.equals(
062 _elementValue, portalCacheClusterEvent._elementValue) &&
063 Validator.equals(
064 _portalCacheClusterEventType,
065 portalCacheClusterEvent._portalCacheClusterEventType)) {
066
067 return true;
068 }
069
070 return false;
071 }
072
073 public String getCacheName() {
074 return _cacheName;
075 }
076
077 public Serializable getElementKey() {
078 return _elementKey;
079 }
080
081 public Serializable getElementValue() {
082 return _elementValue;
083 }
084
085 public PortalCacheClusterEventType getEventType() {
086 return _portalCacheClusterEventType;
087 }
088
089 @Override
090 public int hashCode() {
091 return toString().hashCode();
092 }
093
094 public void setElementValue(Serializable elementValue) {
095 _elementValue = elementValue;
096 }
097
098 @Override
099 public String toString() {
100 StringBundler sb = new StringBundler(7);
101
102 sb.append(_cacheName);
103 sb.append(StringPool.COLON);
104 sb.append(_elementKey);
105 sb.append(StringPool.COLON);
106
107 if (_elementValue != null) {
108 sb.append(_elementValue.toString());
109 sb.append(StringPool.COLON);
110 }
111
112 sb.append(_portalCacheClusterEventType.toString());
113
114 return sb.toString();
115 }
116
117 private String _cacheName;
118 private Serializable _elementKey;
119 private Serializable _elementValue;
120 private PortalCacheClusterEventType _portalCacheClusterEventType;
121
122 }