source: events/src/main/java/geniusweb/events/ActionEvent.java@ 52

Last change on this file since 52 was 52, checked in by ruud, 14 months ago

Fixed small issues in domaineditor.

File size: 1.5 KB
Line 
1package geniusweb.events;
2
3import com.fasterxml.jackson.annotation.JsonCreator;
4import com.fasterxml.jackson.annotation.JsonProperty;
5
6import geniusweb.actions.Action;
7
8/**
9 * Event where a party did an {@link Action}
10 *
11 */
12public class ActionEvent extends AbstractEvent {
13
14 private final Action action;
15
16 /**
17 *
18 * @param action the {@link Action} that was done
19 * @param time the current time to use. see
20 * {@link System#currentTimeMillis()}.
21 */
22 @JsonCreator
23 public ActionEvent(@JsonProperty("action") Action action,
24 @JsonProperty("time") Long time) {
25 super(time);
26 if (action == null) {
27 throw new IllegalArgumentException("Action must not be null");
28 }
29 this.action = action;
30 }
31
32 /**
33 *
34 * @return action done by some party in the system.
35 */
36 public Action getAction() {
37 return action;
38 }
39
40 @Override
41 public String toString() {
42 return this.getClass().getSimpleName() + "[" + getTime() + "," + action
43 + "]";
44 }
45
46 @Override
47 public int hashCode() {
48 final int prime = 31;
49 int result = super.hashCode();
50 result = prime * result + ((action == null) ? 0 : action.hashCode());
51 return result;
52 }
53
54 @Override
55 public boolean equals(Object obj) {
56 if (this == obj)
57 return true;
58 if (!super.equals(obj))
59 return false;
60 if (getClass() != obj.getClass())
61 return false;
62 ActionEvent other = (ActionEvent) obj;
63 if (action == null) {
64 if (other.action != null)
65 return false;
66 } else if (!action.equals(other.action))
67 return false;
68 return true;
69 }
70
71}
Note: See TracBrowser for help on using the repository browser.