Rev | Line | |
---|
[1] | 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 | /**
|
---|
[10] | 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.
|
---|
[1] | 11 | *
|
---|
| 12 | */
|
---|
| 13 | public abstract class ActionWithBid extends AbstractAction {
|
---|
| 14 | private Bid bid;
|
---|
| 15 |
|
---|
| 16 | @JsonCreator
|
---|
| 17 | public ActionWithBid(@JsonProperty("actor") PartyId id,
|
---|
| 18 | @JsonProperty("bid") Bid bid) {
|
---|
| 19 | super(id);
|
---|
| 20 | this.bid = bid;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | /**
|
---|
| 24 | *
|
---|
| 25 | * @return the {@link Bid} that this action is about.
|
---|
| 26 | */
|
---|
| 27 | public 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.