io.contek.zeus.TradeKey Maven / Gradle / Ivy
The newest version!
package io.contek.zeus;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import java.util.Objects;
import static io.contek.zeus.Constants.JOINER;
@Immutable
public final class TradeKey {
private final MarketSymbol marketSymbol;
private final TradeLabel tradeLabel;
private TradeKey(MarketSymbol marketSymbol, TradeLabel tradeLabel) {
this.marketSymbol = marketSymbol;
this.tradeLabel = tradeLabel;
}
public static TradeKey of(MarketSymbol marketSymbol, TradeLabel tradeLabel) {
return new TradeKey(marketSymbol, tradeLabel);
}
public MarketSymbol getMarketSymbol() {
return marketSymbol;
}
public TradeLabel getTradeLabel() {
return tradeLabel;
}
@Override
public boolean equals(@Nullable Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TradeKey orderKey = (TradeKey) o;
return Objects.equals(marketSymbol, orderKey.marketSymbol)
&& Objects.equals(tradeLabel, orderKey.tradeLabel);
}
@Override
public int hashCode() {
return Objects.hash(marketSymbol, tradeLabel);
}
@Override
public String toString() {
return JOINER.join(marketSymbol, tradeLabel);
}
}