From e95092fd435ee8d12836b7930c348063baaadc58 Mon Sep 17 00:00:00 2001 From: Ivan Hetman Date: Mon, 12 Oct 2020 09:39:16 +0300 Subject: [PATCH] Add static Map.Entry methods (#530) --- .../java/org/teavm/classlib/java/util/TMap.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TMap.java b/classlib/src/main/java/org/teavm/classlib/java/util/TMap.java index 032c09b54..4d58b55cc 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TMap.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TMap.java @@ -28,6 +28,22 @@ public interface TMap { V1 getValue(); V1 setValue(V1 value); + + static , V> TComparator> comparingByKey() { + return (a, b) -> a.getKey().compareTo(b.getKey()); + } + + static > TComparator> comparingByValue() { + return (a, b) -> a.getValue().compareTo(b.getValue()); + } + + static TComparator> comparingByKey(TComparator comp) { + return (a, b) -> comp.compare(a.getKey(), b.getKey()); + } + + static TComparator> comparingByValue(TComparator comp) { + return (a, b) -> comp.compare(a.getValue(), b.getValue()); + } } int size();