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

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

  private final ExchangeId exchangeId;
  private final AccountName accountName;

  private AccountId(ExchangeId exchangeId, AccountName accountName) {
    this.exchangeId = exchangeId;
    this.accountName = accountName;
  }

  public static AccountId of(String exchangeId, String accountName) {
    return of(ExchangeId.of(exchangeId), AccountName.of(accountName));
  }

  public static AccountId of(ExchangeId exchangeId, AccountName accountName) {
    return new AccountId(exchangeId, accountName);
  }

  public ExchangeId getExchangeId() {
    return exchangeId;
  }

  public AccountName getAccountName() {
    return accountName;
  }

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy