Converted to interface facet functional injection model

This commit is contained in:
Willem Cazander 2022-01-30 18:05:18 +01:00
parent 8df56173c3
commit 9e806b7669
23 changed files with 368 additions and 418 deletions

View file

@ -1,19 +0,0 @@
package love.distributedrebirth.demo4d.base2t;
/**
*
* @author willemtsade ©Δ 仙上主天
*
*/
public interface BasePartIdentifier {
int ordinal();
String getIdentifierTone();
String getIdentifierLetter();
String getChinaKey();
String getChinaValue();
}

View file

@ -1,13 +0,0 @@
package love.distributedrebirth.demo4d.base2t;
/**
*
* @author willemtsade ©Δ 仙上主天
*
*/
public interface BasePartIdentifierAlt extends BasePartIdentifier {
String getIdentifierAlt();
BasePartIdentifierAltInfo getIdentifierAltInfo();
}

View file

@ -2,57 +2,42 @@ package love.distributedrebirth.demo4d.base2t;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import love.distributedrebirth.demo4d.base2t.facet.BaseFacet;
import love.distributedrebirth.demo4d.base2t.facet.BaseFacetKey;
/** /**
* The distribution by 2. * The distribution by 2.
* @author willemtsade ©Δ 仙上主天 * @author willemtsade ©Δ 仙上主天
* *
*/ */
public enum T02PartBinary implements BasePartIdentifier { public enum T02PartBinary implements BaseFacet {
PART_1("˧","0", "", "low"), PART_1("˧","0", "", "low"),
PART_2("","1", "", "high"), PART_2("","1", "", "high"),
; ;
public static int LENGTH = 2; public static int LENGTH = 2;
private final String identifierTone; private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
private final String identifierLetter;
private final String chinaKey;
private final String chinaValue;
private static final Map<String, T02PartBinary> TONE_MAP = Collections.unmodifiableMap( private static final Map<String, T02PartBinary> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T02PartBinary> CHINA_MAP = Collections.unmodifiableMap( private static final Map<String, T02PartBinary> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v)));
private T02PartBinary(String identifierTone, String identifierLetter, String chinaKey, String chinaValue) { private T02PartBinary(String idTone, String idLetter, String chinaKey, String chinaValue) {
this.identifierTone = identifierTone; this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone);
this.identifierLetter = identifierLetter; this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter);
this.chinaKey = chinaKey; this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey);
this.chinaValue = chinaValue; this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue);
} }
@Override @Override
public String getIdentifierTone() { public Map<BaseFacetKey, Object> getFacetStore() {
return identifierTone; return facetStore;
}
@Override
public String getIdentifierLetter() {
return identifierLetter;
}
@Override
public String getChinaKey() {
return chinaKey;
}
@Override
public String getChinaValue() {
return chinaValue;
} }
public static void forEach(Consumer<T02PartBinary> consumer) { public static void forEach(Consumer<T02PartBinary> consumer) {

View file

@ -2,16 +2,20 @@ package love.distributedrebirth.demo4d.base2t;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import love.distributedrebirth.demo4d.base2t.facet.BaseFacet;
import love.distributedrebirth.demo4d.base2t.facet.BaseFacetKey;
/** /**
* The distribution by 3. * The distribution by 3.
* @author willemtsade ©Δ 仙上主天 * @author willemtsade ©Δ 仙上主天
* *
*/ */
public enum T03PartTrit implements BasePartIdentifier { public enum T03PartTrit implements BaseFacet {
PART_1("˦","0","","1"), PART_1("˦","0","","1"),
PART_2("˧","1","","2"), PART_2("˧","1","","2"),
@ -19,41 +23,22 @@ public enum T03PartTrit implements BasePartIdentifier {
; ;
public static int LENGTH = 3; public static int LENGTH = 3;
private final String identifierTone; private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
private final String identifierLetter;
private final String chinaKey;
private final String chinaValue;
private static final Map<String, T03PartTrit> TONE_MAP = Collections.unmodifiableMap( private static final Map<String, T03PartTrit> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T03PartTrit> CHINA_MAP = Collections.unmodifiableMap( private static final Map<String, T03PartTrit> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v)));
private T03PartTrit(String identifierTone, String identifierLetter, String chinaKey, String chinaValue) { private T03PartTrit(String idTone, String idLetter, String chinaKey, String chinaValue) {
this.identifierTone = identifierTone; this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone);
this.identifierLetter = identifierLetter; this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter);
this.chinaKey = chinaKey; this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey);
this.chinaValue = chinaValue; this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue);
} }
@Override @Override
public String getIdentifierTone() { public Map<BaseFacetKey, Object> getFacetStore() {
return identifierTone; return facetStore;
}
@Override
public String getIdentifierLetter() {
return identifierLetter;
}
@Override
public String getChinaKey() {
return chinaKey;
}
@Override
public String getChinaValue() {
return chinaValue;
} }
public static void forEach(Consumer<T03PartTrit> consumer) { public static void forEach(Consumer<T03PartTrit> consumer) {

View file

@ -2,77 +2,51 @@ package love.distributedrebirth.demo4d.base2t;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; 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. * The distribution by 4.
* @author willemtsade ©Δ 仙上主天 * @author willemtsade ©Δ 仙上主天
* *
*/ */
public enum T04PartQuad implements BasePartIdentifierAlt { public enum T04PartQuad implements BaseFacet,BasePartAlt1,BasePartSplit4 {
PART_1("˥","0","","north","N"), PART_1("˥","0","","north","N"),
PART_2("","1","","east","E"), PART_2("","1","","east", "E"),
PART_3("","2","西","west","W"), PART_3("","2","西","west", "W"),
PART_4("˩","3","","south","S"), PART_4("˩","3","","south","S"),
; ;
public static int LENGTH = 4; public static int LENGTH = 4;
private final String identifierTone; private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
private final String identifierLetter; private static final String ALT_1_NAME = "Cardinal direction";
private final String chinaKey; private static final String ALT_1_WIKI = "https://simple.wikipedia.org/wiki/Cardinal_direction";
private final String chinaValue;
private final String identifierAlt;
private static final Map<String, T04PartQuad> TONE_MAP = Collections.unmodifiableMap( private static final Map<String, T04PartQuad> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T04PartQuad> CHINA_MAP = Collections.unmodifiableMap( private static final Map<String, T04PartQuad> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); 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) { private T04PartQuad(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) {
this.identifierTone = identifierTone; this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone);
this.identifierLetter = identifierLetter; this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter);
this.chinaKey = chinaKey; this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey);
this.chinaValue = chinaValue; this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue);
this.identifierAlt = identifierAlt; 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 @Override
public String getIdentifierTone() { public Map<BaseFacetKey, Object> getFacetStore() {
return identifierTone; return facetStore;
}
@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 static void forEach(Consumer<T04PartQuad> consumer) { public static void forEach(Consumer<T04PartQuad> consumer) {

View file

@ -2,15 +2,19 @@ package love.distributedrebirth.demo4d.base2t;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; 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. * The distribution by 5 called Wuxing.
* @author willemtsade ©Δ 仙上主天 * @author willemtsade ©Δ 仙上主天
*/ */
public enum T05PartPental implements BasePartIdentifier { public enum T05PartPental implements BaseFacet {
PART_1("˥","0","","fire"), PART_1("˥","0","","fire"),
PART_2("˦","1","","water"), PART_2("˦","1","","water"),
@ -20,39 +24,20 @@ public enum T05PartPental implements BasePartIdentifier {
; ;
public static int LENGTH = 5; public static int LENGTH = 5;
private final String identifierTone; private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
private final String identifierLetter;
private final String chinaKey;
private final String chinaValue;
private static final Map<String, T05PartPental> TONE_MAP = Collections.unmodifiableMap( private static final Map<String, T05PartPental> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private T05PartPental(String identifierTone, String identifierLetter, String chinaKey, String chinaValue) { private T05PartPental(String idTone, String idLetter, String chinaKey, String chinaValue) {
this.identifierTone = identifierTone; this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone);
this.identifierLetter = identifierLetter; this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter);
this.chinaKey = chinaKey; this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey);
this.chinaValue = chinaValue; this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue);
} }
@Override @Override
public String getIdentifierTone() { public Map<BaseFacetKey, Object> getFacetStore() {
return identifierTone; return facetStore;
}
@Override
public String getIdentifierLetter() {
return identifierLetter;
}
@Override
public String getChinaKey() {
return chinaKey;
}
@Override
public String getChinaValue() {
return chinaValue;
} }
public static void forEach(Consumer<T05PartPental> consumer) { public static void forEach(Consumer<T05PartPental> consumer) {

View file

@ -2,10 +2,16 @@ package love.distributedrebirth.demo4d.base2t;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; 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. * 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. * 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 ©Δ 仙上主天 * @author willemtsade ©Δ 仙上主天
* *
*/ */
public enum T06PartSeximal implements BasePartIdentifierAlt { public enum T06PartSeximal implements BaseFacet,BasePartAlt1,BasePartSplit6 {
PART_1("˧˥","0","","4","A"), PART_1("˧˥","0","","4","A"),
PART_2("˧˩","1","","5","D"), PART_2("˧˩","1","","5","D"),
@ -24,63 +30,27 @@ public enum T06PartSeximal implements BasePartIdentifierAlt {
; ;
public static int LENGTH = 6; public static int LENGTH = 6;
private final String identifierTone; private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
private final String identifierLetter; private static final String ALT_1_NAME = "ADFGVX cipher";
private final String chinaKey; private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/ADFGVX_cipher";
private final String chinaValue;
private final String identifierAlt;
private static final Map<String, T06PartSeximal> TONE_MAP = Collections.unmodifiableMap( private static final Map<String, T06PartSeximal> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T06PartSeximal> CHINA_MAP = Collections.unmodifiableMap( private static final Map<String, T06PartSeximal> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); 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) { private T06PartSeximal(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) {
this.identifierTone = identifierTone; this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone);
this.identifierLetter = identifierLetter; this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter);
this.chinaKey = chinaKey; this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey);
this.chinaValue = chinaValue; this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue);
this.identifierAlt = identifierAlt; 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 @Override
public String getIdentifierTone() { public Map<BaseFacetKey, Object> getFacetStore() {
return identifierTone; return facetStore;
}
@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 static void forEach(Consumer<T06PartSeximal> consumer) { public static void forEach(Consumer<T06PartSeximal> consumer) {

View file

@ -2,99 +2,71 @@ package love.distributedrebirth.demo4d.base2t;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; 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. * The distribution by 8.
* @author willemtsade ©Δ 仙上主天 * @author willemtsade ©Δ 仙上主天
* *
*/ */
public enum T08PartOctal implements BasePartIdentifierAlt { public enum T08PartOctal implements BaseFacet,BasePartAlt2,BasePartSplit8 {
PART_1("˧˥˩","0","","heart","˥˩˧", 0), // FIXME make 8 tone letters
PART_2("˧˩˥","1","","head","˩˥˧", 3), PART_1("˩","0","","heart","˧˥˩","˥˩˧", 0),
PART_3("˧˥˦","2","","eye","˥˦˧", 6), PART_2("˥","1","","head", "˧˩˥","˩˥˧", 3),
PART_4("˧˩˨","3","","mouth","˩˨˧", 9), PART_3("˦","2","","eye", "˧˥˦","˥˦˧", 6),
PART_5("˧˦˦","4","","arm","˦˦˧", 12), PART_4("˨","3","","mouth","˧˩˨","˩˨˧", 9),
PART_6("˧˨˨","5","","hand","˨˨˧", 15), PART_5("˦","4","","arm", "˧˦˦","˦˦˧", 12),
PART_7("˧˥˥","6","","leg","˥˥˧", 18), PART_6("˨","5","","hand", "˧˨˨","˨˨˧", 15),
PART_8("˧˩˩","7","","feet","˩˩˧", 21), PART_7("˥","6","","leg", "˧˥˥","˥˥˧", 18),
PART_8("˩","7","","feet", "˧˩˩","˩˩˧", 21),
; ;
public static int LENGTH = 8; public static int LENGTH = 8;
public static int BIT_COUNT = 3; public static int BIT_COUNT = 3;
private static final byte BITMASK = 0x07; private static final byte BITMASK = 0x07;
private final String identifierTone; // absolute private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
private final String identifierLetter; private static final String ALT_1_NAME = "Absolute Tone Sequence";
private final String chinaKey; private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Tone_letter";
private final String chinaValue; private static final String ALT_2_NAME = "Relative Tone Sequence";
private final String identifierAlt; // relative private static final String ALT_2_WIKI = "https://en.wikipedia.org/wiki/Tone_letter";
private final int shiftBits;
private static final Map<String, T08PartOctal> TONE_MAP = Collections.unmodifiableMap( private static final Map<String, T08PartOctal> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T08PartOctal> CHINA_MAP = Collections.unmodifiableMap( private static final Map<String, T08PartOctal> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); 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) { private T08PartOctal(String identifierTone, String identifierLetter, String chinaKey, String chinaValue, String alt1Value, String alt2Value, int shiftBits) {
this.identifierTone = identifierTone; this.getFacetStore().put(BaseFacetKey.ID_TONE, identifierTone);
this.identifierLetter = identifierLetter; this.getFacetStore().put(BaseFacetKey.ID_LETTER, identifierLetter);
this.chinaKey = chinaKey; this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey);
this.chinaValue = chinaValue; this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue);
this.identifierAlt = identifierAlt; this.getFacetStore().put(BaseFacetKey.SHIFT_BITS, Integer.valueOf(shiftBits));
this.shiftBits = 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 @Override
public String getIdentifierTone() { public Map<BaseFacetKey, Object> getFacetStore() {
return identifierTone; return facetStore;
}
@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 static T08PartOctal indexOf(T08PartOctal group, int value) { public static T08PartOctal indexOf(T08PartOctal group, int value) {
return T08PartOctal.values()[(value >> group.getShiftBits()) & BITMASK]; return T08PartOctal.values()[(value >> group.getShiftBits()) & BITMASK];
} }
public T02PartBinary splitPartBinary(T03PartTrit part) {
return T02PartBinary.values()[(ordinal() >> part.ordinal()) & 1];
}
public static void forEach(Consumer<T08PartOctal> consumer) { public static void forEach(Consumer<T08PartOctal> consumer) {
for (T08PartOctal value:values()) { for (T08PartOctal value:values()) {
consumer.accept(value); consumer.accept(value);

View file

@ -2,16 +2,21 @@ package love.distributedrebirth.demo4d.base2t;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; 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. * The distribution by 12.
* @author willemtsade ©Δ 仙上主天 * @author willemtsade ©Δ 仙上主天
* *
*/ */
public enum T12PartUncial implements BasePartIdentifierAlt { public enum T12PartUncial implements BaseFacet,BasePartAlt1 {
// TODO: fixup tone letters for 12 parts // TODO: fixup tone letters for 12 parts
PART_1 ("˥","0","","sun","0"), PART_1 ("˥","0","","sun","0"),
@ -29,55 +34,27 @@ public enum T12PartUncial implements BasePartIdentifierAlt {
; ;
public static int LENGTH = 12; public static int LENGTH = 12;
private final String identifierTone; private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
private final String identifierLetter; private static final String ALT_1_NAME = "Transdecimal symbols";
private final String chinaKey; private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Duodecimal#Transdecimal_symbols";
private final String chinaValue;
private final String identifierAlt;
private static final Map<String, T12PartUncial> TONE_MAP = Collections.unmodifiableMap( private static final Map<String, T12PartUncial> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T12PartUncial> CHINA_MAP = Collections.unmodifiableMap( private static final Map<String, T12PartUncial> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); 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) { private T12PartUncial(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) {
this.identifierTone = identifierTone; this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone);
this.identifierLetter = identifierLetter; this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter);
this.chinaKey = chinaKey; this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey);
this.chinaValue = chinaValue; this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue);
this.identifierAlt = identifierAlt; 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 @Override
public String getIdentifierTone() { public Map<BaseFacetKey, Object> getFacetStore() {
return identifierTone; return facetStore;
}
@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 static void forEach(Consumer<T12PartUncial> consumer) { public static void forEach(Consumer<T12PartUncial> consumer) {

View file

@ -2,16 +2,22 @@ package love.distributedrebirth.demo4d.base2t;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; 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. * The distribution by 16.
* @author willemtsade ©Δ 仙上主天 * @author willemtsade ©Δ 仙上主天
* *
*/ */
public enum T16PartHex implements BasePartIdentifierAlt { public enum T16PartHex implements BaseFacet,BasePartAlt1,BasePartSplit16 {
PART_1 ("˧˥˩","0","","hydrogen","1"), PART_1 ("˧˥˩","0","","hydrogen","1"),
PART_2 ("˧˩˥","1","","helium","2"), PART_2 ("˧˩˥","1","","helium","2"),
@ -32,59 +38,27 @@ public enum T16PartHex implements BasePartIdentifierAlt {
; ;
public static int LENGTH = 16; public static int LENGTH = 16;
private final String identifierTone; private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
private final String identifierLetter; private static final String ALT_1_NAME = "Dual-tone multi-frequency signaling";
private final String chinaKey; private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling";
private final String chinaValue;
private final String identifierAlt;
private static final Map<String, T16PartHex> TONE_MAP = Collections.unmodifiableMap( private static final Map<String, T16PartHex> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T16PartHex> CHINA_MAP = Collections.unmodifiableMap( private static final Map<String, T16PartHex> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); 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) { private T16PartHex(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) {
this.identifierTone = identifierTone; this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone);
this.identifierLetter = identifierLetter; this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter);
this.chinaKey = chinaKey; this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey);
this.chinaValue = chinaValue; this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue);
this.identifierAlt = identifierAlt; 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 @Override
public String getIdentifierTone() { public Map<BaseFacetKey, Object> getFacetStore() {
return identifierTone; return facetStore;
}
@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 static void forEach(Consumer<T16PartHex> consumer) { public static void forEach(Consumer<T16PartHex> consumer) {

View file

@ -2,89 +2,66 @@ package love.distributedrebirth.demo4d.base2t;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; 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. * The distribution by 20.
* @author willemtsade ©Δ 仙上主天 * @author willemtsade ©Δ 仙上主天
* *
*/ */
public enum T20PartScore implements BasePartIdentifierAlt { public enum T20PartScore implements BaseFacet,BasePartAlt1 {
PART_1 ("˥","0","","yotta","2"), PART_1 ("˥","0","","yotta","2"),
PART_2 ("˦","1","","zetta","3"), PART_2 ("˦","1","","zetta","3"),
PART_3 ("˧","2","","exa","4"), PART_3 ("˧","2","","exa", "4"),
PART_4 ("˨","3","","peta","5"), PART_4 ("˨","3","","peta", "5"),
PART_5 ("˩","4","","tera","6"), PART_5 ("˩","4","","tera", "6"),
PART_6 ("","5","","giga","7"), PART_6 ("","5","","giga", "7"),
PART_7 ("","6","","mega","8"), PART_7 ("","6","","mega", "8"),
PART_8 ("","7","","kilo","9"), PART_8 ("","7","","kilo", "9"),
PART_9 ("","8","","hecto","C"), PART_9 ("","8","","hecto","C"),
PART_10("","9","","deca","F"), PART_10("","9","","deca", "F"),
PART_11("","A","","deci","G"), PART_11("","A","","deci", "G"),
PART_12("","B","","centi","H"), PART_12("","B","","centi","H"),
PART_13("","C","","milli","J"), PART_13("","C","","milli","J"),
PART_14("","D","","micro","M"), PART_14("","D","","micro","M"),
PART_15("","E","","nano","P"), PART_15("","E","","nano", "P"),
PART_16("","F","","pico","Q"), PART_16("","F","","pico", "Q"),
PART_17("","G","","femto","R"), PART_17("","G","","femto","R"),
PART_18("","H","","atto","V"), PART_18("","H","","atto", "V"),
PART_19("","I","","zepto","W"), PART_19("","I","","zepto","W"),
PART_20("","J","","yocto","X"), PART_20("","J","","yocto","X"),
; ;
public static int LENGTH = 20; public static int LENGTH = 20;
private final String identifierTone; private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
private final String identifierLetter; private static final String ALT_1_NAME = "Open Location Code";
private final String chinaKey; private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Open_Location_Code";
private final String chinaValue;
private final String identifierAlt;
private static final Map<String, T20PartScore> TONE_MAP = Collections.unmodifiableMap( private static final Map<String, T20PartScore> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T20PartScore> CHINA_MAP = Collections.unmodifiableMap( private static final Map<String, T20PartScore> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); 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) { private T20PartScore(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) {
this.identifierTone = identifierTone; this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone);
this.identifierLetter = identifierLetter; this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter);
this.chinaKey = chinaKey; this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey);
this.chinaValue = chinaValue; this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue);
this.identifierAlt = identifierAlt; 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 @Override
public String getIdentifierTone() { public Map<BaseFacetKey, Object> getFacetStore() {
return identifierTone; return facetStore;
}
@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 static void forEach(Consumer<T20PartScore> consumer) { public static void forEach(Consumer<T20PartScore> consumer) {

View file

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

View file

@ -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,
;
}

View file

@ -0,0 +1,8 @@
package love.distributedrebirth.demo4d.base2t.facet;
import java.util.Map;
public interface BaseFacetStore {
Map<BaseFacetKey, Object> getFacetStore();
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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];
}
}

View file

@ -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];
}
}

View file

@ -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];
}
}

View file

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