Converted last T model

This commit is contained in:
Willem Cazander 2022-02-01 18:37:45 +01:00
parent 01a37a1496
commit cbd2d75c5f
5 changed files with 21 additions and 43 deletions

View file

@ -10,7 +10,7 @@ public final class BasePartFactory {
return SUPPORTED_BASES;
}
public static BassBone[] buildBassBonesByBase(int base) {
public static BassBone<?>[] buildBassBonesByBase(int base) {
switch (base) {
case 2:
return T02PartBinary.values();

View file

@ -1,11 +1,5 @@
package love.distributedrebirth.numberxd.base2t;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import love.distributedrebirth.numberxd.base2t.bone.BassBone;
import love.distributedrebirth.numberxd.base2t.bone.BassBoneCoffin;
import love.distributedrebirth.numberxd.base2t.bone.BassBoneName;
@ -17,7 +11,7 @@ import love.distributedrebirth.numberxd.base2t.bone.BassBoneStoreKey;
* @author willemtsade ©Δ 仙上主天
*/
@BassBoneName("T60Sexagesimal")
public enum T60Sexagesimal implements BassBone {
public enum T60Sexagesimal implements BassBone<T60Sexagesimal> {
PART_1 ("˧˩˥","ια","","cow"),
PART_2 ("˧˥˦","ιβ","","chicken"),
@ -85,35 +79,19 @@ public enum T60Sexagesimal implements BassBone {
;
public static int LENGTH() { return values().length; };
private final BassBoneCoffin bfm = BassBoneCoffin.newInstance();
private static final Map<String, T60Sexagesimal> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T60Sexagesimal> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v)));
private final BassBoneCoffin bbc = BassBoneCoffin.newInstance();
private T60Sexagesimal(String idTone, String idLetter, String chinaKey, String chinaValue) {
this.getBBC().putInit(BassBoneStoreKey.ID_TONE, idTone);
this.getBBC().putInit(BassBoneStoreKey.ID_LETTER, idLetter);
this.getBBC().putInit(BassBoneStoreKey.CHINA_KEY, chinaKey);
this.getBBC().putInit(BassBoneStoreKey.CHINA_VALUE, chinaValue);
getBBC().putInit(BassBoneStoreKey.ID_TONE, idTone);
getBBC().putInit(BassBoneStoreKey.ID_LETTER, idLetter);
getBBC().putInit(BassBoneStoreKey.CHINA_KEY, chinaKey);
getBBC().putInit(BassBoneStoreKey.CHINA_VALUE, chinaValue);
getBBC().getMapObject(BassBoneStoreKey.MAP_TONE);
getBBC().getMapObject(BassBoneStoreKey.MAP_CHINA);
}
@Override
public BassBoneCoffin getBBC() {
return bfm;
}
public static void forEach(Consumer<T60Sexagesimal> consumer) {
for (T60Sexagesimal value:values()) {
consumer.accept(value);
}
}
public static T60Sexagesimal valueOfTone(String identifierTone) {
return TONE_MAP.get(identifierTone);
}
public static T60Sexagesimal valueOfChina(String chinaKey) {
return CHINA_MAP.get(chinaKey);
return bbc;
}
}

View file

@ -42,11 +42,11 @@ public class V654Triz implements BaseNumberTyte<V654Triz> {
@Override
public void fillOctalsByClone(T08PartOctalBaseAppender appender) {
T60Sexagesimal.forEach(v -> getValue(v).fillOctalsByClone(appender));
T60Sexagesimal.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender));
}
@Override
public void fillTytesByReference(V009TyteBaseAppender appender) {
T60Sexagesimal.forEach(v -> getValue(v).fillTytesByReference(appender));
T60Sexagesimal.PART_1.staticVoorElk(v -> getValue(v).fillTytesByReference(appender));
}
}

View file

@ -42,6 +42,6 @@ public class V9D8Traz implements BaseNumber<V9D8Traz> {
@Override
public void fillOctalsByClone(T08PartOctalBaseAppender appender) {
T60Sexagesimal.forEach(v -> getValue(v).fillOctalsByClone(appender));
T60Sexagesimal.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender));
}
}

View file

@ -22,17 +22,17 @@ public class T60SexagesimalTest {
@Test
public void testToneMap() {
Assertions.assertEquals(T60Sexagesimal.PART_1, T60Sexagesimal.valueOfTone("˧˩˥"));
Assertions.assertEquals(T60Sexagesimal.PART_2, T60Sexagesimal.valueOfTone("˧˥˦"));
Assertions.assertEquals(T60Sexagesimal.PART_59, T60Sexagesimal.valueOfTone("꜍꜍꜏"));
Assertions.assertEquals(T60Sexagesimal.PART_60, T60Sexagesimal.valueOfTone("꜑꜑꜏"));
Assertions.assertEquals(T60Sexagesimal.PART_1, T60Sexagesimal.PART_1.staticValueOfTone("˧˩˥"));
Assertions.assertEquals(T60Sexagesimal.PART_2, T60Sexagesimal.PART_1.staticValueOfTone("˧˥˦"));
Assertions.assertEquals(T60Sexagesimal.PART_59, T60Sexagesimal.PART_1.staticValueOfTone("꜍꜍꜏"));
Assertions.assertEquals(T60Sexagesimal.PART_60, T60Sexagesimal.PART_1.staticValueOfTone("꜑꜑꜏"));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T60Sexagesimal.PART_1, T60Sexagesimal.valueOfChina(""));
Assertions.assertEquals(T60Sexagesimal.PART_2, T60Sexagesimal.valueOfChina(""));
Assertions.assertEquals(T60Sexagesimal.PART_59, T60Sexagesimal.valueOfChina(""));
Assertions.assertEquals(T60Sexagesimal.PART_60, T60Sexagesimal.valueOfChina(""));
Assertions.assertEquals(T60Sexagesimal.PART_1, T60Sexagesimal.PART_1.staticValueOfChina(""));
Assertions.assertEquals(T60Sexagesimal.PART_2, T60Sexagesimal.PART_1.staticValueOfChina(""));
Assertions.assertEquals(T60Sexagesimal.PART_59, T60Sexagesimal.PART_1.staticValueOfChina(""));
Assertions.assertEquals(T60Sexagesimal.PART_60, T60Sexagesimal.PART_1.staticValueOfChina(""));
}
}