From d5a9f9af6d9931ed5d670f001386a8cc3fb8e76f Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Mon, 31 Jan 2022 17:55:48 +0100 Subject: [PATCH] Added openLC map --- .../distributedrebirth/numberxd/base2t/T20PartScore.java | 6 ++++++ .../numberxd/base2t/T20PartScoreTest.java | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T20PartScore.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T20PartScore.java index 76cce12e..7b232d82 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T20PartScore.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T20PartScore.java @@ -52,6 +52,8 @@ public enum T20PartScore implements BasePart,BasePartAlt3 { Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); private static final Map CHINA_MAP = Collections.unmodifiableMap( Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); + private static final Map OPENLC_MAP = Collections.unmodifiableMap( + Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getAlt3Value(), v -> v))); private T20PartScore(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value, String alt2Value, String alt3Value) { @@ -88,4 +90,8 @@ public enum T20PartScore implements BasePart,BasePartAlt3 { public static T20PartScore valueOfChina(String chinaKey) { return CHINA_MAP.get(chinaKey); } + + public static T20PartScore valueOfOpenLC(String chinaKey) { + return OPENLC_MAP.get(chinaKey); + } } diff --git a/numberxd/src/test/love/distributedrebirth/numberxd/base2t/T20PartScoreTest.java b/numberxd/src/test/love/distributedrebirth/numberxd/base2t/T20PartScoreTest.java index 06389b73..011a324f 100644 --- a/numberxd/src/test/love/distributedrebirth/numberxd/base2t/T20PartScoreTest.java +++ b/numberxd/src/test/love/distributedrebirth/numberxd/base2t/T20PartScoreTest.java @@ -38,4 +38,12 @@ public class T20PartScoreTest { Assertions.assertEquals(T20PartScore.PART_19, T20PartScore.valueOfChina("仄")); Assertions.assertEquals(T20PartScore.PART_20, T20PartScore.valueOfChina("幺")); } + + @Test + public void testOpenLCMap() { + Assertions.assertEquals(T20PartScore.PART_1, T20PartScore.valueOfOpenLC("2")); + Assertions.assertEquals(T20PartScore.PART_2, T20PartScore.valueOfOpenLC("3")); + Assertions.assertEquals(T20PartScore.PART_19, T20PartScore.valueOfOpenLC("W")); + Assertions.assertEquals(T20PartScore.PART_20, T20PartScore.valueOfOpenLC("X")); + } }