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