blob: db688e6ef34c67d30ebb35fb4f642708e43de972 [file] [log] [blame]
tome33cc1a2014-08-25 21:59:41 -07001package org.onlab.onos.event;
2
3/**
4 * Base abstraction of an event.
5 */
6public class AbstractEvent<T extends Enum, S extends Object> implements Event<T, S> {
7
8 private final long time;
9 private final T type;
10 private S subject;
11
12 /**
13 * Creates an event of a given type and for the specified subject and the
14 * current time.
15 *
16 * @param type event type
17 * @param subject event subject
18 */
19 protected AbstractEvent(T type, S subject) {
20 this(type, subject, System.currentTimeMillis());
21 }
22
23 /**
24 * Creates an event of a given type and for the specified subject and time.
25 *
26 * @param type event type
27 * @param subject event subject
28 * @param time occurrence time
29 */
30 protected AbstractEvent(T type, S subject, long time) {
31 this.type = type;
32 this.subject = subject;
33 this.time = time;
34 }
35
36 @Override
37 public long time() {
38 return time;
39 }
40
41 @Override
42 public T type() {
43 return type;
44 }
45
46 @Override
47 public S subject() {
48 return subject;
49 }
50
51}