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

Last change on this file since 24 was 24, checked in by bart, 4 years ago

Fixes an issue with processing maxPower of a vote. Javadoc maven plugin now uses latest version.

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