Last change
on this file since 655 was 505, checked in by wouter, 19 months ago |
#161 restructuring test code, each test program in its own dir.
|
File size:
1.2 KB
|
Line | |
---|
1 | package testcode.actions;
|
---|
2 |
|
---|
3 | import com.fasterxml.jackson.annotation.JsonCreator;
|
---|
4 | import com.fasterxml.jackson.annotation.JsonProperty;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * An {@link Action} containing a bid. Note that the presense of a bid does not
|
---|
8 | * necessarily mean that an offer was placed for this bid.
|
---|
9 | *
|
---|
10 | */
|
---|
11 | public abstract class ActionWithBid extends AbstractAction {
|
---|
12 | private Bid bid;
|
---|
13 |
|
---|
14 | @JsonCreator
|
---|
15 | public ActionWithBid(@JsonProperty("actor") PartyId id,
|
---|
16 | @JsonProperty("bid") Bid bid) {
|
---|
17 | super(id);
|
---|
18 | this.bid = bid;
|
---|
19 | }
|
---|
20 |
|
---|
21 | /**
|
---|
22 | *
|
---|
23 | * @return the {@link Bid} that this action is about.
|
---|
24 | */
|
---|
25 | public Bid getBid() {
|
---|
26 | return bid;
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public int hashCode() {
|
---|
31 | final int prime = 31;
|
---|
32 | int result = super.hashCode();
|
---|
33 | result = prime * result + ((bid == null) ? 0 : bid.hashCode());
|
---|
34 | return result;
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * This should work also for derived classes without extra fields.
|
---|
39 | */
|
---|
40 | @Override
|
---|
41 | public boolean equals(Object obj) {
|
---|
42 | if (this == obj)
|
---|
43 | return true;
|
---|
44 | if (!super.equals(obj))
|
---|
45 | return false;
|
---|
46 | if (getClass() != obj.getClass())
|
---|
47 | return false;
|
---|
48 | ActionWithBid other = (ActionWithBid) obj;
|
---|
49 | if (bid == null) {
|
---|
50 | if (other.bid != null)
|
---|
51 | return false;
|
---|
52 | } else if (!bid.equals(other.bid))
|
---|
53 | return false;
|
---|
54 | return true;
|
---|
55 | }
|
---|
56 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.