KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > notifications > CacheListenerEvent


1 package org.jboss.cache.notifications;
2
3 import java.util.Arrays JavaDoc;
4
5 /**
6  * Internal class that encapsulates a cache listener event
7  *
8  * @author <a HREF="mailto:manik@jboss.org">Manik Surtani</a>
9  * @since 2.0.0
10  */

11 public class CacheListenerEvent
12 {
13    public enum ListenerMethod
14    {
15       NODE_CREATED, NODE_MODIFIED, NODE_REMOVED, NODE_VISITED, NODE_EVICTED, NODE_LOADED, NODE_MOVED, NODE_ACTIVATED,
16       NODE_PASSIVATED, CACHE_STARTED, CACHE_STOPPED, VIEW_CHANGE
17    }
18
19    private ListenerMethod methodName;
20    private Object JavaDoc[] args;
21
22    public CacheListenerEvent(ListenerMethod methodName, Object JavaDoc... args)
23    {
24       this.methodName = methodName;
25       this.args = args;
26    }
27
28    public Object JavaDoc[] getArgs()
29    {
30       return args;
31    }
32
33    public String JavaDoc toString()
34    {
35       StringBuilder JavaDoc b = new StringBuilder JavaDoc("CacheListenerEvent methodName=");
36       b.append(methodName);
37       b.append(" {");
38       for (Object JavaDoc o : args)
39       {
40          b.append(o);
41          b.append(", ");
42       }
43       b.append("}");
44       return b.toString();
45    }
46
47
48    public boolean equals(Object JavaDoc o)
49    {
50       if (this == o) return true;
51       if (o == null || getClass() != o.getClass()) return false;
52
53       CacheListenerEvent event = (CacheListenerEvent) o;
54
55       // Probably incorrect - comparing Object[] arrays with Arrays.equals
56
if (!Arrays.equals(args, event.args)) return false;
57       if (methodName != event.methodName) return false;
58
59       return true;
60    }
61
62    public int hashCode()
63    {
64       int result;
65       result = (methodName != null ? methodName.hashCode() : 0);
66       result = 31 * result + (args != null ? Arrays.hashCode(args) : 0);
67       return result;
68    }
69 }
70
Popular Tags