package testcode.actions; import org.eclipse.jdt.annotation.NonNull; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; /** * An {@link Action} containing a bid. Note that the presense of a bid does not * necessarily mean that an offer was placed for this bid. * */ public abstract class ActionWithBid extends AbstractAction { private final @NonNull Bid bid; @JsonCreator public ActionWithBid(@JsonProperty("actor") @NonNull PartyId actor, @JsonProperty("bid") @NonNull Bid bid) { super(actor); this.bid = bid; } /** * * @return the {@link Bid} that this action is about. */ public @NonNull Bid getBid() { return bid; } @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((bid == null) ? 0 : bid.hashCode()); return result; } /** * This should work also for derived classes without extra fields. */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; ActionWithBid other = (ActionWithBid) obj; if (bid == null) { if (other.bid != null) return false; } else if (!bid.equals(other.bid)) return false; return true; } }