package edu.brown.cs.student.term.profit; import java.util.Objects; /** * class to map holding info for JSON. */ public class StockHolding { private String ticker; private Double realizedGain; private Double unrealizedGain; private int shares; /** * constructor. * @param ticker - stock. * @param realizedGain realized gain. * @param unrealizedGain unrealized gain. * @param shares - number of shares */ public StockHolding(String ticker, Double realizedGain, Double unrealizedGain, int shares) { this.ticker = ticker; this.realizedGain = realizedGain; this.unrealizedGain = unrealizedGain; this.shares = shares; } /** * getter method. * @return realized gain. */ public Double getRealizedGain() { return realizedGain; } /** * getter method. * @return unrealized gain. */ public Double getUnrealizedGain() { return unrealizedGain; } /** * getter method for testing. * @return shares. */ public int getShares() { return shares; } public String getTicker() { return ticker; } @Override public String toString() { return "StockHolding{" + "ticker='" + ticker + '\'' + ", realizedGain=" + realizedGain + ", unrealizedGain=" + unrealizedGain + ", shares=" + shares + '}'; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } StockHolding that = (StockHolding) o; return shares == that.shares && Objects.equals(ticker, that.ticker) && Objects.equals(realizedGain, that.realizedGain) && Objects.equals(unrealizedGain, that.unrealizedGain); } @Override public int hashCode() { return Objects.hash(ticker, realizedGain, unrealizedGain, shares); } }