diff options
| author | Jules Aguillon | 2025-01-12 23:10:40 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2025-01-12 23:10:40 +0100 |
| commit | 3ea5c8d6b7a1211cddbbbfc2de8a7c08151a7e71 (patch) | |
| tree | 38d9877deda9a8fcdfe00451e2a1226129a0ac42 /srcs/juloo.keyboard2 | |
| parent | f7c5b74940e1239f9bd098556b49553d28b8a1e5 (diff) | |
| download | unexpected-keyboard-3ea5c8d6b7a1211cddbbbfc2de8a7c08151a7e71.tar.gz unexpected-keyboard-3ea5c8d6b7a1211cddbbbfc2de8a7c08151a7e71.zip | |
Refactor: KeyValue: Don't require _payload.equals
Don't require _payload.equals to be implemented (correctly) and avoids
inconsistencies with _payload.compareTo, which is required by type.
Diffstat (limited to 'srcs/juloo.keyboard2')
| -rw-r--r-- | srcs/juloo.keyboard2/KeyValue.java | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index 3e8b7ff..359d1d3 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -137,7 +137,9 @@ public final class KeyValue implements Comparable<KeyValue> */ private final Comparable _payload; - /** This field encodes three things: Kind, flags and value. */ + /** This field encodes three things: Kind (KIND_BITS), flags (FLAGS_BITS) and + value (VALUE_BITS). + The meaning of the value depends on the kind. */ private final int _code; public Kind getKind() @@ -267,6 +269,8 @@ public final class KeyValue implements Comparable<KeyValue> d = _code - snd._code; if (d != 0) return d; + // Calls [compareTo] assuming that if [_code] matches, then [_payload] are + // of the same class. return _payload.compareTo(snd._payload); } @@ -275,7 +279,7 @@ public final class KeyValue implements Comparable<KeyValue> { if (snd == null) return false; - return _code == snd._code && _payload.equals(snd._payload); + return _code == snd._code && _payload.compareTo(snd._payload) == 0; } @Override @@ -758,14 +762,6 @@ public final class KeyValue implements Comparable<KeyValue> public abstract int compareTo(Complex snd); @Override - public boolean equals(Object snd) - { - if (snd instanceof Complex) - return compareTo((Complex)snd) == 0; - return false; - } - - @Override public String toString() { return getSymbol(); |
