Added openLC map

This commit is contained in:
Willem Cazander 2022-01-31 17:55:48 +01:00
parent 8b6b4dbc3a
commit d5a9f9af6d
2 changed files with 14 additions and 0 deletions

View file

@ -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<String, T20PartScore> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v)));
private static final Map<String, T20PartScore> 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);
}
}

View file

@ -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"));
}
}