diff --git a/core/src/love/distributedrebirth/demo4d/base2t/BasePartIdentifier.java b/core/src/love/distributedrebirth/demo4d/base2t/BasePartIdentifier.java deleted file mode 100644 index 47428c42..00000000 --- a/core/src/love/distributedrebirth/demo4d/base2t/BasePartIdentifier.java +++ /dev/null @@ -1,19 +0,0 @@ -package love.distributedrebirth.demo4d.base2t; - -/** - * - * @author willemtsade ©Δ∞ 仙上主天 - * - */ -public interface BasePartIdentifier { - - int ordinal(); - - String getIdentifierTone(); - - String getIdentifierLetter(); - - String getChinaKey(); - - String getChinaValue(); -} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/BasePartIdentifierAlt.java b/core/src/love/distributedrebirth/demo4d/base2t/BasePartIdentifierAlt.java deleted file mode 100644 index 47f9a899..00000000 --- a/core/src/love/distributedrebirth/demo4d/base2t/BasePartIdentifierAlt.java +++ /dev/null @@ -1,13 +0,0 @@ -package love.distributedrebirth.demo4d.base2t; - -/** - * - * @author willemtsade ©Δ∞ 仙上主天 - * - */ -public interface BasePartIdentifierAlt extends BasePartIdentifier { - - String getIdentifierAlt(); - - BasePartIdentifierAltInfo getIdentifierAltInfo(); -} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/T02PartBinary.java b/core/src/love/distributedrebirth/demo4d/base2t/T02PartBinary.java index 388dfe98..2116ace1 100644 --- a/core/src/love/distributedrebirth/demo4d/base2t/T02PartBinary.java +++ b/core/src/love/distributedrebirth/demo4d/base2t/T02PartBinary.java @@ -2,57 +2,42 @@ package love.distributedrebirth.demo4d.base2t; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacet; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacetKey; + /** * The distribution by 2. * @author willemtsade ©Δ∞ 仙上主天 * */ -public enum T02PartBinary implements BasePartIdentifier { +public enum T02PartBinary implements BaseFacet { PART_1("˧","0", "低", "low"), PART_2("꜔","1", "高", "high"), ; public static int LENGTH = 2; - private final String identifierTone; - private final String identifierLetter; - private final String chinaKey; - private final String chinaValue; - + private final Map facetStore = new HashMap<>(); private static final Map TONE_MAP = Collections.unmodifiableMap( 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 T02PartBinary(String identifierTone, String identifierLetter, String chinaKey, String chinaValue) { - this.identifierTone = identifierTone; - this.identifierLetter = identifierLetter; - this.chinaKey = chinaKey; - this.chinaValue = chinaValue; + private T02PartBinary(String idTone, String idLetter, String chinaKey, String chinaValue) { + this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone); + this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter); + this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey); + this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue); } @Override - public String getIdentifierTone() { - return identifierTone; - } - - @Override - public String getIdentifierLetter() { - return identifierLetter; - } - - @Override - public String getChinaKey() { - return chinaKey; - } - - @Override - public String getChinaValue() { - return chinaValue; + public Map getFacetStore() { + return facetStore; } public static void forEach(Consumer consumer) { diff --git a/core/src/love/distributedrebirth/demo4d/base2t/T03PartTrit.java b/core/src/love/distributedrebirth/demo4d/base2t/T03PartTrit.java index 9eced71c..8d98c15e 100644 --- a/core/src/love/distributedrebirth/demo4d/base2t/T03PartTrit.java +++ b/core/src/love/distributedrebirth/demo4d/base2t/T03PartTrit.java @@ -2,16 +2,20 @@ package love.distributedrebirth.demo4d.base2t; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacet; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacetKey; + /** * The distribution by 3. * @author willemtsade ©Δ∞ 仙上主天 * */ -public enum T03PartTrit implements BasePartIdentifier { +public enum T03PartTrit implements BaseFacet { PART_1("˦","0","一","1"), PART_2("˧","1","二","2"), @@ -19,41 +23,22 @@ public enum T03PartTrit implements BasePartIdentifier { ; public static int LENGTH = 3; - private final String identifierTone; - private final String identifierLetter; - private final String chinaKey; - private final String chinaValue; - + private final Map facetStore = new HashMap<>(); private static final Map TONE_MAP = Collections.unmodifiableMap( 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 T03PartTrit(String identifierTone, String identifierLetter, String chinaKey, String chinaValue) { - this.identifierTone = identifierTone; - this.identifierLetter = identifierLetter; - this.chinaKey = chinaKey; - this.chinaValue = chinaValue; + private T03PartTrit(String idTone, String idLetter, String chinaKey, String chinaValue) { + this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone); + this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter); + this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey); + this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue); } @Override - public String getIdentifierTone() { - return identifierTone; - } - - @Override - public String getIdentifierLetter() { - return identifierLetter; - } - - @Override - public String getChinaKey() { - return chinaKey; - } - - @Override - public String getChinaValue() { - return chinaValue; + public Map getFacetStore() { + return facetStore; } public static void forEach(Consumer consumer) { diff --git a/core/src/love/distributedrebirth/demo4d/base2t/T04PartQuad.java b/core/src/love/distributedrebirth/demo4d/base2t/T04PartQuad.java index ed8b1c51..82c327ab 100644 --- a/core/src/love/distributedrebirth/demo4d/base2t/T04PartQuad.java +++ b/core/src/love/distributedrebirth/demo4d/base2t/T04PartQuad.java @@ -2,77 +2,51 @@ package love.distributedrebirth.demo4d.base2t; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacet; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacetKey; +import love.distributedrebirth.demo4d.base2t.facet.BasePartAlt1; +import love.distributedrebirth.demo4d.base2t.facet.BasePartSplit4; + /** * The distribution by 4. * @author willemtsade ©Δ∞ 仙上主天 * */ -public enum T04PartQuad implements BasePartIdentifierAlt { +public enum T04PartQuad implements BaseFacet,BasePartAlt1,BasePartSplit4 { PART_1("˥","0","北","north","N"), - PART_2("꜒","1","東","east","E"), - PART_3("꜖","2","西","west","W"), + PART_2("꜒","1","東","east", "E"), + PART_3("꜖","2","西","west", "W"), PART_4("˩","3","南","south","S"), ; public static int LENGTH = 4; - private final String identifierTone; - private final String identifierLetter; - private final String chinaKey; - private final String chinaValue; - private final String identifierAlt; - + private final Map facetStore = new HashMap<>(); + private static final String ALT_1_NAME = "Cardinal direction"; + private static final String ALT_1_WIKI = "https://simple.wikipedia.org/wiki/Cardinal_direction"; private static final Map TONE_MAP = Collections.unmodifiableMap( 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 BasePartIdentifierAltInfo ALT_INFO = new BasePartIdentifierAltInfo( - "Cardinal direction","https://simple.wikipedia.org/wiki/Cardinal_direction"); - private T04PartQuad(String identifierTone, String identifierLetter, String chinaKey, String chinaValue, String identifierAlt) { - this.identifierTone = identifierTone; - this.identifierLetter = identifierLetter; - this.chinaKey = chinaKey; - this.chinaValue = chinaValue; - this.identifierAlt = identifierAlt; + private T04PartQuad(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) { + this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone); + this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter); + this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey); + this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getFacetStore().put(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getFacetStore().put(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getFacetStore().put(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); } @Override - public String getIdentifierTone() { - return identifierTone; - } - - @Override - public String getIdentifierLetter() { - return identifierLetter; - } - - @Override - public String getChinaKey() { - return chinaKey; - } - - @Override - public String getChinaValue() { - return chinaValue; - } - - @Override - public String getIdentifierAlt() { - return identifierAlt; - } - - @Override - public BasePartIdentifierAltInfo getIdentifierAltInfo() { - return ALT_INFO; - } - - public T02PartBinary splitPartBinary(T02PartBinary part) { - return T02PartBinary.values()[(ordinal() >> part.ordinal()) & 1]; + public Map getFacetStore() { + return facetStore; } public static void forEach(Consumer consumer) { diff --git a/core/src/love/distributedrebirth/demo4d/base2t/T05PartPental.java b/core/src/love/distributedrebirth/demo4d/base2t/T05PartPental.java index 2d314ecb..68baa07c 100644 --- a/core/src/love/distributedrebirth/demo4d/base2t/T05PartPental.java +++ b/core/src/love/distributedrebirth/demo4d/base2t/T05PartPental.java @@ -2,15 +2,19 @@ package love.distributedrebirth.demo4d.base2t; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacet; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacetKey; + /** * The distribution by 5 called Wuxing. * @author willemtsade ©Δ∞ 仙上主天 */ -public enum T05PartPental implements BasePartIdentifier { +public enum T05PartPental implements BaseFacet { PART_1("˥","0","火","fire"), PART_2("˦","1","水","water"), @@ -20,39 +24,20 @@ public enum T05PartPental implements BasePartIdentifier { ; public static int LENGTH = 5; - private final String identifierTone; - private final String identifierLetter; - private final String chinaKey; - private final String chinaValue; - + private final Map facetStore = new HashMap<>(); private static final Map TONE_MAP = Collections.unmodifiableMap( Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); - private T05PartPental(String identifierTone, String identifierLetter, String chinaKey, String chinaValue) { - this.identifierTone = identifierTone; - this.identifierLetter = identifierLetter; - this.chinaKey = chinaKey; - this.chinaValue = chinaValue; + private T05PartPental(String idTone, String idLetter, String chinaKey, String chinaValue) { + this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone); + this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter); + this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey); + this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue); } @Override - public String getIdentifierTone() { - return identifierTone; - } - - @Override - public String getIdentifierLetter() { - return identifierLetter; - } - - @Override - public String getChinaKey() { - return chinaKey; - } - - @Override - public String getChinaValue() { - return chinaValue; + public Map getFacetStore() { + return facetStore; } public static void forEach(Consumer consumer) { diff --git a/core/src/love/distributedrebirth/demo4d/base2t/T06PartSeximal.java b/core/src/love/distributedrebirth/demo4d/base2t/T06PartSeximal.java index cfd0aeca..18ee06d6 100644 --- a/core/src/love/distributedrebirth/demo4d/base2t/T06PartSeximal.java +++ b/core/src/love/distributedrebirth/demo4d/base2t/T06PartSeximal.java @@ -2,10 +2,16 @@ package love.distributedrebirth.demo4d.base2t; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; +import love.distributedrebirth.demo4d.base2t.facet.BasePartAlt1; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacet; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacetKey; +import love.distributedrebirth.demo4d.base2t.facet.BasePartSplit6; + /** * TThe distribution by 6. * NOTE: The sexi karlson-speaker is china design 3=6 and 6=9 and in quad space, zero is the result. @@ -13,7 +19,7 @@ import java.util.stream.Collectors; * @author willemtsade ©Δ∞ 仙上主天 * */ -public enum T06PartSeximal implements BasePartIdentifierAlt { +public enum T06PartSeximal implements BaseFacet,BasePartAlt1,BasePartSplit6 { PART_1("˧˥","0","四","4","A"), PART_2("˧˩","1","五","5","D"), @@ -24,63 +30,27 @@ public enum T06PartSeximal implements BasePartIdentifierAlt { ; public static int LENGTH = 6; - private final String identifierTone; - private final String identifierLetter; - private final String chinaKey; - private final String chinaValue; - private final String identifierAlt; - + private final Map facetStore = new HashMap<>(); + private static final String ALT_1_NAME = "ADFGVX cipher"; + private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/ADFGVX_cipher"; private static final Map TONE_MAP = Collections.unmodifiableMap( 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 BasePartIdentifierAltInfo ALT_INFO = new BasePartIdentifierAltInfo( - "ADFGVX cipher","https://en.wikipedia.org/wiki/ADFGVX_cipher"); - private T06PartSeximal(String identifierTone, String identifierLetter, String chinaKey, String chinaValue, String identifierAlt) { - this.identifierTone = identifierTone; - this.identifierLetter = identifierLetter; - this.chinaKey = chinaKey; - this.chinaValue = chinaValue; - this.identifierAlt = identifierAlt; + private T06PartSeximal(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) { + this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone); + this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter); + this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey); + this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getFacetStore().put(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getFacetStore().put(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getFacetStore().put(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); } @Override - public String getIdentifierTone() { - return identifierTone; - } - - @Override - public String getIdentifierLetter() { - return identifierLetter; - } - - @Override - public String getChinaKey() { - return chinaKey; - } - - @Override - public String getChinaValue() { - return chinaValue; - } - - @Override - public String getIdentifierAlt() { - return identifierAlt; - } - - @Override - public BasePartIdentifierAltInfo getIdentifierAltInfo() { - return ALT_INFO; - } - - public T02PartBinary splitPartBinary() { - return T02PartBinary.values()[ordinal() & 1]; - } - - public T03PartTrit splitPartTrit() { - return T03PartTrit.values()[ordinal() >> 1]; + public Map getFacetStore() { + return facetStore; } public static void forEach(Consumer consumer) { diff --git a/core/src/love/distributedrebirth/demo4d/base2t/T08PartOctal.java b/core/src/love/distributedrebirth/demo4d/base2t/T08PartOctal.java index 9268383b..7058112d 100644 --- a/core/src/love/distributedrebirth/demo4d/base2t/T08PartOctal.java +++ b/core/src/love/distributedrebirth/demo4d/base2t/T08PartOctal.java @@ -2,99 +2,71 @@ package love.distributedrebirth.demo4d.base2t; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacet; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacetKey; +import love.distributedrebirth.demo4d.base2t.facet.BasePartAlt2; +import love.distributedrebirth.demo4d.base2t.facet.BasePartSplit8; + /** * The distribution by 8. * @author willemtsade ©Δ∞ 仙上主天 * */ -public enum T08PartOctal implements BasePartIdentifierAlt { +public enum T08PartOctal implements BaseFacet,BasePartAlt2,BasePartSplit8 { - PART_1("˧˥˩","0","心","heart","˥˩˧", 0), - PART_2("˧˩˥","1","頭","head","˩˥˧", 3), - PART_3("˧˥˦","2","眼","eye","˥˦˧", 6), - PART_4("˧˩˨","3","嘴","mouth","˩˨˧", 9), - PART_5("˧˦˦","4","臂","arm","˦˦˧", 12), - PART_6("˧˨˨","5","手","hand","˨˨˧", 15), - PART_7("˧˥˥","6","肢","leg","˥˥˧", 18), - PART_8("˧˩˩","7","腳","feet","˩˩˧", 21), + // FIXME make 8 tone letters + PART_1("˩","0","心","heart","˧˥˩","˥˩˧", 0), + PART_2("˥","1","頭","head", "˧˩˥","˩˥˧", 3), + PART_3("˦","2","眼","eye", "˧˥˦","˥˦˧", 6), + PART_4("˨","3","嘴","mouth","˧˩˨","˩˨˧", 9), + PART_5("˦","4","臂","arm", "˧˦˦","˦˦˧", 12), + PART_6("˨","5","手","hand", "˧˨˨","˨˨˧", 15), + PART_7("˥","6","肢","leg", "˧˥˥","˥˥˧", 18), + PART_8("˩","7","腳","feet", "˧˩˩","˩˩˧", 21), ; public static int LENGTH = 8; public static int BIT_COUNT = 3; private static final byte BITMASK = 0x07; - private final String identifierTone; // absolute - private final String identifierLetter; - private final String chinaKey; - private final String chinaValue; - private final String identifierAlt; // relative - private final int shiftBits; + private final Map facetStore = new HashMap<>(); + private static final String ALT_1_NAME = "Absolute Tone Sequence"; + private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Tone_letter"; + private static final String ALT_2_NAME = "Relative Tone Sequence"; + private static final String ALT_2_WIKI = "https://en.wikipedia.org/wiki/Tone_letter"; private static final Map TONE_MAP = Collections.unmodifiableMap( 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 BasePartIdentifierAltInfo ALT_INFO = new BasePartIdentifierAltInfo( - "Tone Letters","https://en.wikipedia.org/wiki/Tone_letter"); - private T08PartOctal(String identifierTone, String identifierLetter, String chinaKey, String chinaValue, String identifierAlt, int shiftBits) { - this.identifierTone = identifierTone; - this.identifierLetter = identifierLetter; - this.chinaKey = chinaKey; - this.chinaValue = chinaValue; - this.identifierAlt = identifierAlt; - this.shiftBits = shiftBits; + private T08PartOctal(String identifierTone, String identifierLetter, String chinaKey, String chinaValue, String alt1Value, String alt2Value, int shiftBits) { + this.getFacetStore().put(BaseFacetKey.ID_TONE, identifierTone); + this.getFacetStore().put(BaseFacetKey.ID_LETTER, identifierLetter); + this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey); + this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getFacetStore().put(BaseFacetKey.SHIFT_BITS, Integer.valueOf(shiftBits)); + this.getFacetStore().put(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getFacetStore().put(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getFacetStore().put(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); + this.getFacetStore().put(BaseFacetKey.ALT_2_VALUE, alt2Value); + this.getFacetStore().put(BaseFacetKey.ALT_2_NAME, ALT_2_NAME); + this.getFacetStore().put(BaseFacetKey.ALT_2_WIKI, ALT_2_WIKI); } @Override - public String getIdentifierTone() { - return identifierTone; - } - - @Override - public String getIdentifierLetter() { - return identifierLetter; - } - - @Override - public String getChinaKey() { - return chinaKey; - } - - @Override - public String getChinaValue() { - return chinaValue; - } - - @Override - public String getIdentifierAlt() { - return identifierAlt; - } - - @Override - public BasePartIdentifierAltInfo getIdentifierAltInfo() { - return ALT_INFO; - } - - public int getShiftBits() { - return shiftBits; - } - - public int ordinalOf(T08PartOctal group) { - return ordinal() << group.getShiftBits(); + public Map getFacetStore() { + return facetStore; } public static T08PartOctal indexOf(T08PartOctal group, int value) { return T08PartOctal.values()[(value >> group.getShiftBits()) & BITMASK]; } - public T02PartBinary splitPartBinary(T03PartTrit part) { - return T02PartBinary.values()[(ordinal() >> part.ordinal()) & 1]; - } - public static void forEach(Consumer consumer) { for (T08PartOctal value:values()) { consumer.accept(value); diff --git a/core/src/love/distributedrebirth/demo4d/base2t/T12PartUncial.java b/core/src/love/distributedrebirth/demo4d/base2t/T12PartUncial.java index 92c669bf..9f266d1f 100644 --- a/core/src/love/distributedrebirth/demo4d/base2t/T12PartUncial.java +++ b/core/src/love/distributedrebirth/demo4d/base2t/T12PartUncial.java @@ -2,16 +2,21 @@ package love.distributedrebirth.demo4d.base2t; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacet; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacetKey; +import love.distributedrebirth.demo4d.base2t.facet.BasePartAlt1; + /** * The distribution by 12. * @author willemtsade ©Δ∞ 仙上主天 * */ -public enum T12PartUncial implements BasePartIdentifierAlt { +public enum T12PartUncial implements BaseFacet,BasePartAlt1 { // TODO: fixup tone letters for 12 parts PART_1 ("˥","0","日","sun","0"), @@ -29,55 +34,27 @@ public enum T12PartUncial implements BasePartIdentifierAlt { ; public static int LENGTH = 12; - private final String identifierTone; - private final String identifierLetter; - private final String chinaKey; - private final String chinaValue; - private final String identifierAlt; - + private final Map facetStore = new HashMap<>(); + private static final String ALT_1_NAME = "Transdecimal symbols"; + private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Duodecimal#Transdecimal_symbols"; private static final Map TONE_MAP = Collections.unmodifiableMap( 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 BasePartIdentifierAltInfo ALT_INFO = new BasePartIdentifierAltInfo( - "Transdecimal symbols","https://en.wikipedia.org/wiki/Duodecimal#Transdecimal_symbols"); - private T12PartUncial(String identifierTone, String identifierLetter, String chinaKey, String chinaValue, String identifierAlt) { - this.identifierTone = identifierTone; - this.identifierLetter = identifierLetter; - this.chinaKey = chinaKey; - this.chinaValue = chinaValue; - this.identifierAlt = identifierAlt; + private T12PartUncial(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) { + this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone); + this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter); + this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey); + this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getFacetStore().put(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getFacetStore().put(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getFacetStore().put(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); } @Override - public String getIdentifierTone() { - return identifierTone; - } - - @Override - public String getIdentifierLetter() { - return identifierLetter; - } - - @Override - public String getChinaKey() { - return chinaKey; - } - - @Override - public String getChinaValue() { - return chinaValue; - } - - @Override - public String getIdentifierAlt() { - return identifierAlt; - } - - @Override - public BasePartIdentifierAltInfo getIdentifierAltInfo() { - return ALT_INFO; + public Map getFacetStore() { + return facetStore; } public static void forEach(Consumer consumer) { diff --git a/core/src/love/distributedrebirth/demo4d/base2t/T16PartHex.java b/core/src/love/distributedrebirth/demo4d/base2t/T16PartHex.java index 479f952f..06fe5e4e 100644 --- a/core/src/love/distributedrebirth/demo4d/base2t/T16PartHex.java +++ b/core/src/love/distributedrebirth/demo4d/base2t/T16PartHex.java @@ -2,16 +2,22 @@ package love.distributedrebirth.demo4d.base2t; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacet; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacetKey; +import love.distributedrebirth.demo4d.base2t.facet.BasePartAlt1; +import love.distributedrebirth.demo4d.base2t.facet.BasePartSplit16; + /** * The distribution by 16. * @author willemtsade ©Δ∞ 仙上主天 * */ -public enum T16PartHex implements BasePartIdentifierAlt { +public enum T16PartHex implements BaseFacet,BasePartAlt1,BasePartSplit16 { PART_1 ("˧˥˩","0","氫","hydrogen","1"), PART_2 ("˧˩˥","1","氦","helium","2"), @@ -32,59 +38,27 @@ public enum T16PartHex implements BasePartIdentifierAlt { ; public static int LENGTH = 16; - private final String identifierTone; - private final String identifierLetter; - private final String chinaKey; - private final String chinaValue; - private final String identifierAlt; - + private final Map facetStore = new HashMap<>(); + private static final String ALT_1_NAME = "Dual-tone multi-frequency signaling"; + private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling"; private static final Map TONE_MAP = Collections.unmodifiableMap( 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 BasePartIdentifierAltInfo ALT_INFO = new BasePartIdentifierAltInfo( - "Dual-tone multi-frequency signaling","https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling"); - private T16PartHex(String identifierTone, String identifierLetter, String chinaKey, String chinaValue, String identifierAlt) { - this.identifierTone = identifierTone; - this.identifierLetter = identifierLetter; - this.chinaKey = chinaKey; - this.chinaValue = chinaValue; - this.identifierAlt = identifierAlt; + private T16PartHex(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) { + this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone); + this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter); + this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey); + this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getFacetStore().put(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getFacetStore().put(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getFacetStore().put(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); } @Override - public String getIdentifierTone() { - return identifierTone; - } - - @Override - public String getIdentifierLetter() { - return identifierLetter; - } - - @Override - public String getChinaKey() { - return chinaKey; - } - - @Override - public String getChinaValue() { - return chinaValue; - } - - @Override - public String getIdentifierAlt() { - return identifierAlt; - } - - @Override - public BasePartIdentifierAltInfo getIdentifierAltInfo() { - return ALT_INFO; - } - - public T02PartBinary splitPartBinary(T04PartQuad part) { - return T02PartBinary.values()[(ordinal() >> part.ordinal()) & 1]; + public Map getFacetStore() { + return facetStore; } public static void forEach(Consumer consumer) { diff --git a/core/src/love/distributedrebirth/demo4d/base2t/T20PartScore.java b/core/src/love/distributedrebirth/demo4d/base2t/T20PartScore.java index f13d202f..5c64c251 100644 --- a/core/src/love/distributedrebirth/demo4d/base2t/T20PartScore.java +++ b/core/src/love/distributedrebirth/demo4d/base2t/T20PartScore.java @@ -2,89 +2,66 @@ package love.distributedrebirth.demo4d.base2t; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacet; +import love.distributedrebirth.demo4d.base2t.facet.BaseFacetKey; +import love.distributedrebirth.demo4d.base2t.facet.BasePartAlt1; + /** * The distribution by 20. * @author willemtsade ©Δ∞ 仙上主天 * */ -public enum T20PartScore implements BasePartIdentifierAlt { +public enum T20PartScore implements BaseFacet,BasePartAlt1 { PART_1 ("˥","0","尧","yotta","2"), PART_2 ("˦","1","泽","zetta","3"), - PART_3 ("˧","2","艾","exa","4"), - PART_4 ("˨","3","拍","peta","5"), - PART_5 ("˩","4","太","tera","6"), - PART_6 ("꜒","5","吉","giga","7"), - PART_7 ("꜓","6","兆","mega","8"), - PART_8 ("꜔","7","千","kilo","9"), + PART_3 ("˧","2","艾","exa", "4"), + PART_4 ("˨","3","拍","peta", "5"), + PART_5 ("˩","4","太","tera", "6"), + PART_6 ("꜒","5","吉","giga", "7"), + PART_7 ("꜓","6","兆","mega", "8"), + PART_8 ("꜔","7","千","kilo", "9"), PART_9 ("꜕","8","百","hecto","C"), - PART_10("꜖","9","十","deca","F"), - PART_11("꜈","A","分","deci","G"), + PART_10("꜖","9","十","deca", "F"), + PART_11("꜈","A","分","deci", "G"), PART_12("꜉","B","厘","centi","H"), PART_13("꜊","C","毫","milli","J"), PART_14("꜋","D","微","micro","M"), - PART_15("꜌","E","纳","nano","P"), - PART_16("꜍","F","皮","pico","Q"), + PART_15("꜌","E","纳","nano", "P"), + PART_16("꜍","F","皮","pico", "Q"), PART_17("꜎","G","飞","femto","R"), - PART_18("꜏","H","阿","atto","V"), + PART_18("꜏","H","阿","atto", "V"), PART_19("꜐","I","仄","zepto","W"), PART_20("꜑","J","幺","yocto","X"), ; public static int LENGTH = 20; - private final String identifierTone; - private final String identifierLetter; - private final String chinaKey; - private final String chinaValue; - private final String identifierAlt; - + private final Map facetStore = new HashMap<>(); + private static final String ALT_1_NAME = "Open Location Code"; + private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Open_Location_Code"; private static final Map TONE_MAP = Collections.unmodifiableMap( 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 BasePartIdentifierAltInfo ALT_INFO = new BasePartIdentifierAltInfo( - "Open Location Code","https://en.wikipedia.org/wiki/Open_Location_Code"); - private T20PartScore(String identifierTone, String identifierLetter, String chinaKey, String chinaValue, String identifierAlt) { - this.identifierTone = identifierTone; - this.identifierLetter = identifierLetter; - this.chinaKey = chinaKey; - this.chinaValue = chinaValue; - this.identifierAlt = identifierAlt; + private T20PartScore(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) { + this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone); + this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter); + this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey); + this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getFacetStore().put(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getFacetStore().put(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getFacetStore().put(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); } @Override - public String getIdentifierTone() { - return identifierTone; - } - - @Override - public String getIdentifierLetter() { - return identifierLetter; - } - - @Override - public String getChinaKey() { - return chinaKey; - } - - @Override - public String getChinaValue() { - return chinaValue; - } - - @Override - public String getIdentifierAlt() { - return identifierAlt; - } - - @Override - public BasePartIdentifierAltInfo getIdentifierAltInfo() { - return ALT_INFO; + public Map getFacetStore() { + return facetStore; } public static void forEach(Consumer consumer) { diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BaseFacet.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BaseFacet.java new file mode 100644 index 00000000..09bdc659 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BaseFacet.java @@ -0,0 +1,27 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +/** + * + * @author willemtsade ©Δ∞ 仙上主天 + * + */ +public interface BaseFacet extends BaseFacetStore { + + int ordinal(); + + default String getIdentifierTone() { + return (String)getFacetStore().get(BaseFacetKey.ID_TONE); + } + + default String getIdentifierLetter() { + return (String)getFacetStore().get(BaseFacetKey.ID_LETTER); + } + + default String getChinaKey() { + return (String)getFacetStore().get(BaseFacetKey.CHINA_KEY); + } + + default String getChinaValue() { + return (String)getFacetStore().get(BaseFacetKey.CHINA_VALUE); + } +} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BaseFacetKey.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BaseFacetKey.java new file mode 100644 index 00000000..020615c7 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BaseFacetKey.java @@ -0,0 +1,24 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +public enum BaseFacetKey { + + ID_TONE, + ID_LETTER, + CHINA_KEY, + CHINA_VALUE, + SHIFT_BITS, + + ALT_1_VALUE, + ALT_1_NAME, + ALT_1_WIKI, + ALT_2_VALUE, + ALT_2_NAME, + ALT_2_WIKI, + ALT_3_VALUE, + ALT_3_NAME, + ALT_3_WIKI, + ALT_4_VALUE, + ALT_4_NAME, + ALT_4_WIKI, + ; +} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BaseFacetStore.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BaseFacetStore.java new file mode 100644 index 00000000..84bda9c1 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BaseFacetStore.java @@ -0,0 +1,8 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +import java.util.Map; + +public interface BaseFacetStore { + + Map getFacetStore(); +} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt1.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt1.java new file mode 100644 index 00000000..54f4ec38 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt1.java @@ -0,0 +1,16 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +public interface BasePartAlt1 extends BaseFacet { + + default String getAlt1Value() { + return (String)getFacetStore().get(BaseFacetKey.ALT_1_VALUE); + } + + default String getAlt1Name() { + return (String)getFacetStore().get(BaseFacetKey.ALT_1_NAME); + } + + default String getAlt1Wiki() { + return (String)getFacetStore().get(BaseFacetKey.ALT_1_WIKI); + } +} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt2.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt2.java new file mode 100644 index 00000000..e95db4dd --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt2.java @@ -0,0 +1,16 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +public interface BasePartAlt2 extends BasePartAlt1 { + + default String getAlt2Value() { + return (String)getFacetStore().get(BaseFacetKey.ALT_2_VALUE); + } + + default String getAlt2Name() { + return (String)getFacetStore().get(BaseFacetKey.ALT_2_NAME); + } + + default String getAlt2Wiki() { + return (String)getFacetStore().get(BaseFacetKey.ALT_2_WIKI); + } +} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt3.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt3.java new file mode 100644 index 00000000..5104dbf0 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt3.java @@ -0,0 +1,16 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +public interface BasePartAlt3 extends BasePartAlt2 { + + default String getAlt3Value() { + return (String)getFacetStore().get(BaseFacetKey.ALT_3_VALUE); + } + + default String getAlt3Name() { + return (String)getFacetStore().get(BaseFacetKey.ALT_3_NAME); + } + + default String getAlt3Wiki() { + return (String)getFacetStore().get(BaseFacetKey.ALT_3_WIKI); + } +} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt4.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt4.java new file mode 100644 index 00000000..418ef597 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartAlt4.java @@ -0,0 +1,16 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +public interface BasePartAlt4 extends BasePartAlt3 { + + default String getAlt4Value() { + return (String)getFacetStore().get(BaseFacetKey.ALT_4_VALUE); + } + + default String getAlt4Name() { + return (String)getFacetStore().get(BaseFacetKey.ALT_4_NAME); + } + + default String getAlt4Wiki() { + return (String)getFacetStore().get(BaseFacetKey.ALT_4_WIKI); + } +} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartShiftBits.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartShiftBits.java new file mode 100644 index 00000000..65290fd3 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartShiftBits.java @@ -0,0 +1,8 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +public interface BasePartShiftBits extends BaseFacet { + + default Integer getShiftBits() { + return (Integer)getFacetStore().get(BaseFacetKey.SHIFT_BITS); + } +} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit16.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit16.java new file mode 100644 index 00000000..464974cd --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit16.java @@ -0,0 +1,11 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +import love.distributedrebirth.demo4d.base2t.T02PartBinary; +import love.distributedrebirth.demo4d.base2t.T04PartQuad; + +public interface BasePartSplit16 extends BaseFacet { + + default T02PartBinary splitPartBinary(T04PartQuad part) { + return T02PartBinary.values()[(ordinal() >> part.ordinal()) & 1]; + } +} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit4.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit4.java new file mode 100644 index 00000000..8da785e6 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit4.java @@ -0,0 +1,10 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +import love.distributedrebirth.demo4d.base2t.T02PartBinary; + +public interface BasePartSplit4 extends BaseFacet { + + default T02PartBinary splitPartBinary(T02PartBinary part) { + return T02PartBinary.values()[(ordinal() >> part.ordinal()) & 1]; + } +} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit6.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit6.java new file mode 100644 index 00000000..be395c92 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit6.java @@ -0,0 +1,15 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +import love.distributedrebirth.demo4d.base2t.T02PartBinary; +import love.distributedrebirth.demo4d.base2t.T03PartTrit; + +public interface BasePartSplit6 extends BaseFacet { + + default T02PartBinary splitPartBinary() { + return T02PartBinary.values()[ordinal() & 1]; + } + + default T03PartTrit splitPartTrit() { + return T03PartTrit.values()[ordinal() >> 1]; + } +} diff --git a/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit8.java b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit8.java new file mode 100644 index 00000000..7303ce79 --- /dev/null +++ b/core/src/love/distributedrebirth/demo4d/base2t/facet/BasePartSplit8.java @@ -0,0 +1,16 @@ +package love.distributedrebirth.demo4d.base2t.facet; + +import love.distributedrebirth.demo4d.base2t.T02PartBinary; +import love.distributedrebirth.demo4d.base2t.T03PartTrit; +import love.distributedrebirth.demo4d.base2t.T08PartOctal; + +public interface BasePartSplit8 extends BasePartShiftBits { + + default T02PartBinary splitPartBinary(T03PartTrit part) { + return T02PartBinary.values()[(ordinal() >> part.ordinal()) & 1]; + } + + default int ordinalOf(T08PartOctal group) { + return ordinal() << group.getShiftBits(); + } +}