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

io.contek.zeus.MarketId Maven / Gradle / Ivy

There is a newer version: 2.29.0
Show 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 MarketId {

  private final ExchangeId exchangeId;
  private final MarketSymbol marketSymbol;

  private MarketId(ExchangeId exchangeId, MarketSymbol marketSymbol) {
    this.exchangeId = exchangeId;
    this.marketSymbol = marketSymbol;
  }

  public static MarketId of(String exchangeId, String marketSymbol) {
    return of(ExchangeId.of(exchangeId), MarketSymbol.of(marketSymbol));
  }

  public static MarketId of(ExchangeId exchangeId, MarketSymbol marketSymbol) {
    return new MarketId(exchangeId, marketSymbol);
  }

  public ExchangeId getExchangeId() {
    return exchangeId;
  }

  public MarketSymbol getMarketSymbol() {
    return marketSymbol;
  }

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy