source: java2python/jackson-t/src/test/javaactions/testcode/actions/ActionWithBid.java@ 958

Last change on this file since 958 was 741, checked in by wouter, 11 months ago

#252 fixed error message, added new tests, fixed existing tests

File size: 1.2 KB
Line 
1package testcode.actions;
2
3import com.fasterxml.jackson.annotation.JsonCreator;
4import 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 */
11public abstract class ActionWithBid extends AbstractAction {
12 private Bid bid;
13
14 @JsonCreator
15 public ActionWithBid(@JsonProperty("actor") PartyId actor,
16 @JsonProperty("bid") Bid bid) {
17 super(actor);
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.