This commit is contained in:
Willem Cazander 2022-02-02 18:55:21 +01:00
parent 4bfb7b94eb
commit f959704f08
19 changed files with 66 additions and 46 deletions

View file

@ -37,14 +37,14 @@ public class BasePartRenderer extends ImGuiRendererMain {
ImGui.begin("Base part", widgetOpen); ImGui.begin("Base part", widgetOpen);
List<String> bases = new ArrayList<>(); List<String> bases = new ArrayList<>();
for (int base:BasePartFactory.getSupportedBases()) { for (int base:BasePartFactory.INSTANCE.BãßBases()) {
bases.add(Integer.toString(base)); bases.add(Integer.toString(base));
} }
String[] items = new String[bases.size()]; String[] items = new String[bases.size()];
items = bases.toArray(items); items = bases.toArray(items);
String selectedItem = items[selectedBasePart.get()]; String selectedItem = items[selectedBasePart.get()];
Integer baseNumber = Integer.valueOf(selectedItem); Integer baseNumber = Integer.valueOf(selectedItem);
BãßBȍőnPartʸᴰ<?>[] baseParts = BasePartFactory.buildBassBonesByBase(baseNumber); BãßBȍőnPartʸᴰ<?>[] baseParts = BasePartFactory.INSTANCE.BãßBuildPartsByBase(baseNumber);
ImGui.text("Base:"); ImGui.text("Base:");
ImGui.sameLine(); ImGui.sameLine();

View file

@ -61,7 +61,7 @@ public interface BãßBȍőnEnumSetʸᴰ<T> extends BãßBȍőnEnumʸᴰ<T> {
return values[resultIndex]; return values[resultIndex];
} }
default void staticVoorElk(Consumer<T> consumer) { default void BãßVoorElk(Consumer<T> consumer) {
for (T value:BãßInstances()) { for (T value:BãßInstances()) {
consumer.accept(value); consumer.accept(value);
} }

View file

@ -5,18 +5,13 @@ public interface BãßBȍőnEnumʸᴰ<T> {
String name(); String name();
// Bȍőn prefix is for set instance enum object called BãßBȍőnEnumSetʸᴰ
// Bãß prefix is for single instance enum objects called BãßBȍőnEnumInstanceʸᴰ
default String BȍőnNaam() { default String BȍőnNaam() {
return name(); return name();
} }
default String BȍőnNaamI18N() {
return BãßNaam() + BãßBȍőnConstantsʸᴰ.STR_DOT + name();
}
default String BãßNaam() {
return getClass().getAnnotation(BãßBȍőnInfoʸᴰ.class).name();
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
default T[] BãßInstances() { default T[] BãßInstances() {
try { try {
@ -26,4 +21,24 @@ public interface BãßBȍőnEnumʸᴰ<T> {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
default String BãßNaam() {
return getClass().getAnnotation(BãßBȍőnInfoʸᴰ.class).name();
}
default String BãßPurpose() {
return getClass().getAnnotation(BãßBȍőnInfoʸᴰ.class).purpose();
}
default String BãßAuthorNaam() {
return getClass().getAnnotation(BãßBȍőnAuthorInfoʸᴰ.class).name();
}
default String BãßAuthorCopyright() {
return getClass().getAnnotation(BãßBȍőnAuthorInfoʸᴰ.class).copyright();
}
default String BȍőnNaamI18N() {
return BãßNaam() + BãßBȍőnConstantsʸᴰ.STR_DOT + name();
}
} }

View file

@ -55,11 +55,11 @@ public class GroßGetậl6ˢᴰ implements BaseNumberTyte<GroßGetậl6ˢᴰ> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T12PartUncial.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T12PartUncial.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
@Override @Override
public void fillTytesByReference(BaseAppenderTyte appender) { public void fillTytesByReference(BaseAppenderTyte appender) {
T12PartUncial.PART_1.staticVoorElk(v -> getValue(v).fillTytesByReference(appender)); T12PartUncial.PART_1.BãßVoorElk(v -> getValue(v).fillTytesByReference(appender));
} }
} }

View file

@ -53,11 +53,11 @@ public class KlompGetậl4ˢᴰ implements BaseNumberTyte<KlompGetậl4ˢᴰ> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T08PartOctal.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T08PartOctal.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
@Override @Override
public void fillTytesByReference(BaseAppenderTyte appender) { public void fillTytesByReference(BaseAppenderTyte appender) {
T08PartOctal.PART_1.staticVoorElk(v -> getValue(v).fillTytesByReference(appender)); T08PartOctal.PART_1.BãßVoorElk(v -> getValue(v).fillTytesByReference(appender));
} }
} }

View file

@ -64,7 +64,7 @@ public class Base2Terminator {
private List<T08PartOctal> base2ReadOctals(int...values) { private List<T08PartOctal> base2ReadOctals(int...values) {
List<T08PartOctal> octals = new ArrayList<>(); List<T08PartOctal> octals = new ArrayList<>();
for (int value:values) { for (int value:values) {
T08PartOctal.PART_1.staticVoorElk(v -> octals.add(T08PartOctal.indexOf(v, value))); T08PartOctal.PART_1.BãßVoorElk(v -> octals.add(T08PartOctal.indexOf(v, value)));
} }
return octals; return octals;
} }

View file

@ -1,18 +1,23 @@
package love.distributedrebirth.numberxd.base2t; package love.distributedrebirth.numberxd.base2t;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.bassboonyd.BãßBȍőnEnumInstanceʸᴰ;
import love.distributedrebirth.bassboonyd.BãßBȍőnInfoʸᴰ;
import love.distributedrebirth.numberxd.base2t.part.BãßBȍőnPartʸᴰ; import love.distributedrebirth.numberxd.base2t.part.BãßBȍőnPartʸᴰ;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public final class BasePartFactory { @BãßBȍőnInfoʸᴰ(name = "BasePartFactory", purpose = "Factory to access the bases.")
public enum BasePartFactory implements BãßBȍőnEnumInstanceʸᴰ<BasePartFactory> {
INSTANCE;
private static final int[] SUPPORTED_BASES = {2,3,4,5,6,7,8,10,11,12,16,20,60}; private static final int[] SUPPORTED_BASES = {2,3,4,5,6,7,8,10,11,12,16,20,60};
public static int[] getSupportedBases() { public int[] BãßBases() {
return SUPPORTED_BASES; return SUPPORTED_BASES;
} }
public static BãßBȍőnPartʸᴰ<?>[] buildBassBonesByBase(int base) { public BãßBȍőnPartʸᴰ<?>[] BãßBuildPartsByBase(int base) {
switch (base) { switch (base) {
case 2: case 2:
return T02PartBinary.values(); return T02PartBinary.values();

View file

@ -44,6 +44,6 @@ public final class V006Tixte implements BaseNumber<V006Tixte> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T02PartBinary.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T02PartBinary.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
} }

View file

@ -45,7 +45,7 @@ public final class V009Tyte implements BaseNumberTyte<V009Tyte> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T03PartTrit.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T03PartTrit.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
@Override @Override

View file

@ -52,11 +52,11 @@ public final class V012Tord implements BaseNumberTyte<V012Tord> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T02PartBinary.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T02PartBinary.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
@Override @Override
public void fillTytesByReference(BaseAppenderTyte appender) { public void fillTytesByReference(BaseAppenderTyte appender) {
T02PartBinary.PART_1.staticVoorElk(v -> getValue(v).fillTytesByReference(appender)); T02PartBinary.PART_1.BãßVoorElk(v -> getValue(v).fillTytesByReference(appender));
} }
} }

View file

@ -49,11 +49,11 @@ public final class V01BTemvig implements BaseNumberTyte<V01BTemvig> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T03PartTrit.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T03PartTrit.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
@Override @Override
public void fillTytesByReference(BaseAppenderTyte appender) { public void fillTytesByReference(BaseAppenderTyte appender) {
T03PartTrit.PART_1.staticVoorElk(v -> getValue(v).fillTytesByReference(appender)); T03PartTrit.PART_1.BãßVoorElk(v -> getValue(v).fillTytesByReference(appender));
} }
} }

View file

@ -58,11 +58,11 @@ public final class V024Teger implements BaseNumberTyte<V024Teger> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T02PartBinary.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T02PartBinary.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
@Override @Override
public void fillTytesByReference(BaseAppenderTyte appender) { public void fillTytesByReference(BaseAppenderTyte appender) {
T02PartBinary.PART_1.staticVoorElk(v -> getValue(v).fillTytesByReference(appender)); T02PartBinary.PART_1.BãßVoorElk(v -> getValue(v).fillTytesByReference(appender));
} }
} }

View file

@ -43,6 +43,6 @@ public final class V02ATraw implements BaseNumber<V02ATraw> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T07PartPlanIt.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T07PartPlanIt.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
} }

View file

@ -60,11 +60,11 @@ public final class V048Tong implements BaseNumberTyte<V048Tong> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T02PartBinary.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T02PartBinary.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
@Override @Override
public void fillTytesByReference(BaseAppenderTyte appender) { public void fillTytesByReference(BaseAppenderTyte appender) {
T02PartBinary.PART_1.staticVoorElk(v -> getValue(v).fillTytesByReference(appender)); T02PartBinary.PART_1.BãßVoorElk(v -> getValue(v).fillTytesByReference(appender));
} }
} }

View file

@ -74,11 +74,11 @@ public final class V090Tocta implements BaseNumberTyte<V090Tocta> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T02PartBinary.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T02PartBinary.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
@Override @Override
public void fillTytesByReference(BaseAppenderTyte appender) { public void fillTytesByReference(BaseAppenderTyte appender) {
T02PartBinary.PART_1.staticVoorElk(v -> getValue(v).fillTytesByReference(appender)); T02PartBinary.PART_1.BãßVoorElk(v -> getValue(v).fillTytesByReference(appender));
} }
} }

View file

@ -43,11 +43,11 @@ public class V654Triz implements BaseNumberTyte<V654Triz> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T60PartSexagesimal.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T60PartSexagesimal.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
@Override @Override
public void fillTytesByReference(BaseAppenderTyte appender) { public void fillTytesByReference(BaseAppenderTyte appender) {
T60PartSexagesimal.PART_1.staticVoorElk(v -> getValue(v).fillTytesByReference(appender)); T60PartSexagesimal.PART_1.BãßVoorElk(v -> getValue(v).fillTytesByReference(appender));
} }
} }

View file

@ -43,6 +43,6 @@ public class V9D8Traz implements BaseNumber<V9D8Traz> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T60PartSexagesimal.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T60PartSexagesimal.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
} }

View file

@ -44,11 +44,11 @@ public class VCA8Tath implements BaseNumberTyte<VCA8Tath> {
@Override @Override
public void fillOctalsByClone(BaseAppenderOctal appender) { public void fillOctalsByClone(BaseAppenderOctal appender) {
T02PartBinary.PART_1.staticVoorElk(v -> getValue(v).fillOctalsByClone(appender)); T02PartBinary.PART_1.BãßVoorElk(v -> getValue(v).fillOctalsByClone(appender));
} }
@Override @Override
public void fillTytesByReference(BaseAppenderTyte appender) { public void fillTytesByReference(BaseAppenderTyte appender) {
T02PartBinary.PART_1.staticVoorElk(v -> getValue(v).fillTytesByReference(appender)); T02PartBinary.PART_1.BãßVoorElk(v -> getValue(v).fillTytesByReference(appender));
} }
} }

View file

@ -14,7 +14,7 @@ public class BasePartFactoryTest {
@Test @Test
public void testSupportedBases() { public void testSupportedBases() {
int[] bases = BasePartFactory.getSupportedBases(); int[] bases = BasePartFactory.INSTANCE.BãßBases();
Assertions.assertNotNull(bases); Assertions.assertNotNull(bases);
Assertions.assertTrue(bases.length > 1); Assertions.assertTrue(bases.length > 1);
Assertions.assertTrue(bases.length < 100); Assertions.assertTrue(bases.length < 100);
@ -23,8 +23,8 @@ public class BasePartFactoryTest {
@Test @Test
public void testGlobalChinaKeyMap() { public void testGlobalChinaKeyMap() {
Map<String,String> global = new HashMap<>(); Map<String,String> global = new HashMap<>();
for (int base:BasePartFactory.getSupportedBases()) { for (int base:BasePartFactory.INSTANCE.BãßBases()) {
for (BãßBȍőnPartʸᴰ<?> part:BasePartFactory.buildBassBonesByBase(base)) { for (BãßBȍőnPartʸᴰ<?> part:BasePartFactory.INSTANCE.BãßBuildPartsByBase(base)) {
Assertions.assertFalse(global.containsKey(part.getChinaKey())); Assertions.assertFalse(global.containsKey(part.getChinaKey()));
global.put(part.getChinaKey(), part.getChinaValue()); global.put(part.getChinaKey(), part.getChinaValue());
} }
@ -35,8 +35,8 @@ public class BasePartFactoryTest {
@Test @Test
public void testGlobalChinaValueMap() { public void testGlobalChinaValueMap() {
Map<String,String> global = new HashMap<>(); Map<String,String> global = new HashMap<>();
for (int base:BasePartFactory.getSupportedBases()) { for (int base:BasePartFactory.INSTANCE.BãßBases()) {
for (BãßBȍőnPartʸᴰ<?> part:BasePartFactory.buildBassBonesByBase(base)) { for (BãßBȍőnPartʸᴰ<?> part:BasePartFactory.INSTANCE.BãßBuildPartsByBase(base)) {
Assertions.assertFalse(global.containsKey(part.getChinaValue())); Assertions.assertFalse(global.containsKey(part.getChinaValue()));
global.put(part.getChinaValue(), part.getChinaValue()); global.put(part.getChinaValue(), part.getChinaValue());
} }
@ -48,8 +48,8 @@ public class BasePartFactoryTest {
public void testGlobalToneMap() { public void testGlobalToneMap() {
boolean duplicate = false; boolean duplicate = false;
Map<String,String> global = new HashMap<>(); Map<String,String> global = new HashMap<>();
for (int base:BasePartFactory.getSupportedBases()) { for (int base:BasePartFactory.INSTANCE.BãßBases()) {
for (BãßBȍőnPartʸᴰ<?> part:BasePartFactory.buildBassBonesByBase(base)) { for (BãßBȍőnPartʸᴰ<?> part:BasePartFactory.INSTANCE.BãßBuildPartsByBase(base)) {
if (global.containsKey(part.getIdentifierTone())) { if (global.containsKey(part.getIdentifierTone())) {
duplicate = true; duplicate = true;
break; break;
@ -65,8 +65,8 @@ public class BasePartFactoryTest {
public void testGlobalLetterMap() { public void testGlobalLetterMap() {
boolean duplicate = false; boolean duplicate = false;
Map<String,String> global = new HashMap<>(); Map<String,String> global = new HashMap<>();
for (int base:BasePartFactory.getSupportedBases()) { for (int base:BasePartFactory.INSTANCE.BãßBases()) {
for (BãßBȍőnPartʸᴰ<?> part:BasePartFactory.buildBassBonesByBase(base)) { for (BãßBȍőnPartʸᴰ<?> part:BasePartFactory.INSTANCE.BãßBuildPartsByBase(base)) {
if (global.containsKey(part.getIdentifierLetter())) { if (global.containsKey(part.getIdentifierLetter())) {
duplicate = true; duplicate = true;
break; break;