package geniusweb.actions; import java.util.List; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import geniusweb.issuevalue.Bid; /** * A statement from a Party that some bids are better and worse than * {@link #getBid()} bid. Typically this is a response to a CompareWithBid * inform * */ public class Comparison extends ActionWithBid { private List better; private List worse; /** * @param id the party id that made this comparison * @param bid the bid that is compared wiht * @param better list of bids that are better than bid * @param worse list of bids that are worse than bid */ @JsonCreator public Comparison(@JsonProperty("id") PartyId id, @JsonProperty("bid") Bid bid, @JsonProperty("better") List better, @JsonProperty("worse") List worse) { super(id, bid); if (bid == null || better == null || worse == null) throw new IllegalArgumentException( "bid, better and worse must not be null"); this.better = better; this.worse = worse; } /** * @return All bids that are better than the bid. Maybe empty * */ public List getBetter() { return better; } /** * @return All bids that are worse than the bid. Maybe empty * */ public List getWorse() { return worse; } @Override public String toString() { return "Comparison[" + getActor() + "," + getBid() + ",better=" + better + ",worse=" + worse + "]"; } @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((better == null) ? 0 : better.hashCode()); result = prime * result + ((worse == null) ? 0 : worse.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; Comparison other = (Comparison) obj; if (better == null) { if (other.better != null) return false; } else if (!better.equals(other.better)) return false; if (worse == null) { if (other.worse != null) return false; } else if (!worse.equals(other.worse)) return false; return true; } }