source: events/src/main/java/geniusweb/actions/ActionWithBid.java@ 4

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

Initial Release

File size: 1.1 KB
Line 
1package geniusweb.actions;
2
3import com.fasterxml.jackson.annotation.JsonCreator;
4import com.fasterxml.jackson.annotation.JsonProperty;
5
6import geniusweb.issuevalue.Bid;
7
8/**
9 * An {@link Action} containing a bid.
10 *
11 */
12public abstract class ActionWithBid extends AbstractAction {
13 private Bid bid;
14
15 @JsonCreator
16 public ActionWithBid(@JsonProperty("actor") PartyId id,
17 @JsonProperty("bid") Bid bid) {
18 super(id);
19 this.bid = bid;
20 }
21
22 /**
23 *
24 * @return the {@link Bid} that this action is about.
25 */
26 public Bid getBid() {
27 return bid;
28 }
29
30 @Override
31 public int hashCode() {
32 final int prime = 31;
33 int result = super.hashCode();
34 result = prime * result + ((bid == null) ? 0 : bid.hashCode());
35 return result;
36 }
37
38 /**
39 * This should work also for derived classes without extra fields.
40 */
41 @Override
42 public boolean equals(Object obj) {
43 if (this == obj)
44 return true;
45 if (!super.equals(obj))
46 return false;
47 if (getClass() != obj.getClass())
48 return false;
49 ActionWithBid other = (ActionWithBid) obj;
50 if (bid == null) {
51 if (other.bid != null)
52 return false;
53 } else if (!bid.equals(other.bid))
54 return false;
55 return true;
56 }
57}
Note: See TracBrowser for help on using the repository browser.