mirror of
https://github.com/boldsuck/haveno.git
synced 2024-12-22 20:19:21 +00:00
fix equals and hashcode of trade, crypto, and traditional currencies
This commit is contained in:
parent
9c3e405fe0
commit
3cdfa0fa27
4 changed files with 20 additions and 8 deletions
|
@ -19,10 +19,8 @@ package haveno.core.locale;
|
||||||
|
|
||||||
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public final class CryptoCurrency extends TradeCurrency {
|
public final class CryptoCurrency extends TradeCurrency {
|
||||||
// http://boschista.deviantart.com/journal/Cool-ASCII-Symbols-214218618
|
// http://boschista.deviantart.com/journal/Cool-ASCII-Symbols-214218618
|
||||||
private final static String PREFIX = "✦ ";
|
private final static String PREFIX = "✦ ";
|
||||||
|
|
|
@ -19,19 +19,16 @@ package haveno.core.locale;
|
||||||
|
|
||||||
import haveno.common.proto.ProtobufferRuntimeException;
|
import haveno.common.proto.ProtobufferRuntimeException;
|
||||||
import haveno.common.proto.persistable.PersistablePayload;
|
import haveno.common.proto.persistable.PersistablePayload;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@ToString
|
@ToString
|
||||||
@Getter
|
@Getter
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class TradeCurrency implements PersistablePayload, Comparable<TradeCurrency> {
|
public abstract class TradeCurrency implements PersistablePayload, Comparable<TradeCurrency> {
|
||||||
protected final String code;
|
protected final String code;
|
||||||
@EqualsAndHashCode.Exclude
|
|
||||||
protected final String name;
|
protected final String name;
|
||||||
|
|
||||||
public TradeCurrency(String code, String name) {
|
public TradeCurrency(String code, String name) {
|
||||||
|
@ -82,4 +79,23 @@ public abstract class TradeCurrency implements PersistablePayload, Comparable<Tr
|
||||||
return this.name.compareTo(other.name);
|
return this.name.compareTo(other.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (obj == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj instanceof TradeCurrency) {
|
||||||
|
TradeCurrency other = (TradeCurrency) obj;
|
||||||
|
return code.equals(other.code);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return code.hashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,14 +36,12 @@ package haveno.core.locale;
|
||||||
|
|
||||||
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.util.Currency;
|
import java.util.Currency;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString
|
@ToString
|
||||||
@Getter
|
@Getter
|
||||||
public final class TraditionalCurrency extends TradeCurrency {
|
public final class TraditionalCurrency extends TradeCurrency {
|
||||||
|
|
|
@ -187,7 +187,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
||||||
@Override
|
@Override
|
||||||
protected void activate() {
|
protected void activate() {
|
||||||
// We want to have it updated in case an asset got removed
|
// We want to have it updated in case an asset got removed
|
||||||
allCryptoCurrencies = FXCollections.observableArrayList(CurrencyUtil.getActiveSortedCryptoCurrencies( filterManager));
|
allCryptoCurrencies = FXCollections.observableArrayList(CurrencyUtil.getActiveSortedCryptoCurrencies(filterManager));
|
||||||
allCryptoCurrencies.removeAll(cryptoCurrencies);
|
allCryptoCurrencies.removeAll(cryptoCurrencies);
|
||||||
|
|
||||||
activateGeneralOptions();
|
activateGeneralOptions();
|
||||||
|
|
Loading…
Reference in a new issue