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

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

  private final ExchangeId exchangeId;
  private final AssetSymbol assetSymbol;

  private AssetId(ExchangeId exchangeId, AssetSymbol assetSymbol) {
    this.exchangeId = exchangeId;
    this.assetSymbol = assetSymbol;
  }

  public static AssetId of(String exchangeId, String assetSymbol) {
    return of(ExchangeId.of(exchangeId), AssetSymbol.of(assetSymbol));
  }

  public static AssetId of(ExchangeId exchangeId, AssetSymbol assetSymbol) {
    return new AssetId(exchangeId, assetSymbol);
  }

  public ExchangeId getExchangeId() {
    return exchangeId;
  }

  public AssetSymbol getAssetSymbol() {
    return assetSymbol;
  }

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy