All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.contek.zeus.TradeId 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 TradeId {

  private final ExchangeId exchangeId;
  private final TradeKey tradeKey;

  private TradeId(ExchangeId exchangeId, TradeKey tradeKey) {
    this.exchangeId = exchangeId;
    this.tradeKey = tradeKey;
  }

  public static TradeId of(ExchangeId exchangeId, TradeKey orderKey) {
    return new TradeId(exchangeId, orderKey);
  }

  public ExchangeId getExchangeId() {
    return exchangeId;
  }

  public TradeKey getTradeKey() {
    return tradeKey;
  }

  @Override
  public boolean equals(@Nullable Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    TradeId accountId = (TradeId) o;
    return exchangeId.equals(accountId.exchangeId) && tradeKey.equals(accountId.tradeKey);
  }

  @Override
  public int hashCode() {
    return Objects.hash(exchangeId, tradeKey);
  }

  @Override
  public String toString() {
    return JOINER.join(exchangeId, tradeKey);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy