Line | |
---|
1 | package geniusweb.actions;
|
---|
2 |
|
---|
3 | import com.fasterxml.jackson.annotation.JsonCreator;
|
---|
4 | import com.fasterxml.jackson.annotation.JsonProperty;
|
---|
5 |
|
---|
6 | import geniusweb.issuevalue.Bid;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * An {@link Action} containing a bid.
|
---|
10 | *
|
---|
11 | */
|
---|
12 | public 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.