io.contek.zeus.IndexId Maven / Gradle / Ivy
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 IndexId {
private final ExchangeId exchangeId;
private final IndexSymbol indexSymbol;
private IndexId(ExchangeId exchangeId, IndexSymbol indexSymbol) {
this.exchangeId = exchangeId;
this.indexSymbol = indexSymbol;
}
public static IndexId of(String exchangeId, String indexSymbol) {
return of(ExchangeId.of(exchangeId), IndexSymbol.of(indexSymbol));
}
public static IndexId of(ExchangeId exchangeId, IndexSymbol indexSymbol) {
return new IndexId(exchangeId, indexSymbol);
}
public ExchangeId getExchangeId() {
return exchangeId;
}
public IndexSymbol getIndexSymbol() {
return indexSymbol;
}
@Override
public boolean equals(@Nullable Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IndexId accountId = (IndexId) o;
return exchangeId.equals(accountId.exchangeId) && indexSymbol.equals(accountId.indexSymbol);
}
@Override
public int hashCode() {
return Objects.hash(exchangeId, indexSymbol);
}
@Override
public String toString() {
return JOINER.join(exchangeId, indexSymbol);
}
}