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

Last change on this file since 1355 was 1116, checked in by wouter, 2 months ago

#363 small cleanup in test code

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