From a31757a349548b8789e46125e51a529a2e4b048b Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Tue, 1 Feb 2022 00:26:11 +0100 Subject: [PATCH] Converted to BaseFacetMap storage bean --- .../numberxd/base2t/T02PartBinary.java | 16 +++---- .../numberxd/base2t/T03PartTrit.java | 16 +++---- .../numberxd/base2t/T04PartQuad.java | 22 +++++----- .../numberxd/base2t/T05PartPental.java | 28 ++++++------ .../numberxd/base2t/T06PartSeximal.java | 22 +++++----- .../numberxd/base2t/T07PartPlanIt.java | 22 +++++----- .../numberxd/base2t/T08PartOctal.java | 30 ++++++------- .../numberxd/base2t/T12PartUncial.java | 22 +++++----- .../numberxd/base2t/T16PartHex.java | 22 +++++----- .../numberxd/base2t/T20PartScore.java | 34 +++++++-------- .../numberxd/base2t/T60Sexagesimal.java | 16 +++---- .../numberxd/base2t/facet/BaseFacetMap.java | 43 +++++++++++++++++++ .../numberxd/base2t/facet/BaseFacetStore.java | 4 +- .../numberxd/base2t/facet/BasePart.java | 8 ++-- .../numberxd/base2t/facet/BasePartAlt1.java | 6 +-- .../numberxd/base2t/facet/BasePartAlt2.java | 6 +-- .../numberxd/base2t/facet/BasePartAlt3.java | 6 +-- .../numberxd/base2t/facet/BasePartAlt4.java | 6 +-- .../base2t/facet/BasePartShiftBits.java | 2 +- 19 files changed, 186 insertions(+), 145 deletions(-) create mode 100644 numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BaseFacetMap.java diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T02PartBinary.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T02PartBinary.java index 1e1ea735..d863a2f2 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T02PartBinary.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T02PartBinary.java @@ -2,13 +2,13 @@ package love.distributedrebirth.numberxd.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.numberxd.base2t.facet.BasePart; import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; /** * The distribution by 2. @@ -22,22 +22,22 @@ public enum T02PartBinary implements BasePart { ; public static int LENGTH() { return values().length; }; - private final Map facetStore = new HashMap<>(); + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); 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 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); + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); } @Override - public Map getFacetStore() { - return facetStore; + public BaseFacetMap getBFM() { + return bfm; } public static void forEach(Consumer consumer) { diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T03PartTrit.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T03PartTrit.java index 96350fea..ca836b3c 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T03PartTrit.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T03PartTrit.java @@ -2,13 +2,13 @@ package love.distributedrebirth.numberxd.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.numberxd.base2t.facet.BasePart; import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; /** * The distribution by 3. @@ -23,22 +23,22 @@ public enum T03PartTrit implements BasePart { ; public static int LENGTH() { return values().length; }; - private final Map facetStore = new HashMap<>(); + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); 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 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); + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); } @Override - public Map getFacetStore() { - return facetStore; + public BaseFacetMap getBFM() { + return bfm; } public static void forEach(Consumer consumer) { diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T04PartQuad.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T04PartQuad.java index 0e91d8c8..db80572e 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T04PartQuad.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T04PartQuad.java @@ -2,13 +2,13 @@ package love.distributedrebirth.numberxd.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.numberxd.base2t.facet.BasePart; import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt1; import love.distributedrebirth.numberxd.base2t.facet.BasePartSplit4; @@ -26,7 +26,7 @@ public enum T04PartQuad implements BasePart,BasePartAlt1,BasePartSplit4 { ; public static int LENGTH() { return values().length; }; - private final Map facetStore = new HashMap<>(); + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); 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( @@ -35,18 +35,18 @@ public enum T04PartQuad implements BasePart,BasePartAlt1,BasePartSplit4 { Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); 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); + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getBFM().putInit(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getBFM().putInit(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); } @Override - public Map getFacetStore() { - return facetStore; + public BaseFacetMap getBFM() { + return bfm; } public static void forEach(Consumer consumer) { diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T05PartPental.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T05PartPental.java index 82bff04e..ec118b2f 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T05PartPental.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T05PartPental.java @@ -2,7 +2,6 @@ package love.distributedrebirth.numberxd.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; @@ -10,6 +9,7 @@ import java.util.stream.Collectors; import love.distributedrebirth.numberxd.base2t.facet.BasePart; import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt2; import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; /** * The distribution by 5 called Wuxing. @@ -30,28 +30,28 @@ public enum T05PartPental implements BasePart,BasePartAlt2 { private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Pentagram"; private static final String ALT_2_NAME = "Pythagorean Interpretations"; private static final String ALT_2_WIKI = "http://wisdomofhypatia.com/OM/BA/PP.html"; - private final Map facetStore = new HashMap<>(); + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); 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 T05PartPental(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value, String alt2Value) { - 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); - 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); + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getBFM().putInit(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getBFM().putInit(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); + this.getBFM().putInit(BaseFacetKey.ALT_2_VALUE, alt2Value); + this.getBFM().putInit(BaseFacetKey.ALT_2_NAME, ALT_2_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_2_WIKI, ALT_2_WIKI); } @Override - public Map getFacetStore() { - return facetStore; + public BaseFacetMap getBFM() { + return bfm; } public static void forEach(Consumer consumer) { diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T06PartSeximal.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T06PartSeximal.java index 56cb4051..3fc11743 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T06PartSeximal.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T06PartSeximal.java @@ -2,13 +2,13 @@ package love.distributedrebirth.numberxd.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.numberxd.base2t.facet.BasePart; import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt1; import love.distributedrebirth.numberxd.base2t.facet.BasePartSplit6; @@ -30,7 +30,7 @@ public enum T06PartSeximal implements BasePart,BasePartAlt1,BasePartSplit6 { ; public static int LENGTH() { return values().length; }; - private final Map facetStore = new HashMap<>(); + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); 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( @@ -39,18 +39,18 @@ public enum T06PartSeximal implements BasePart,BasePartAlt1,BasePartSplit6 { Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); 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); + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getBFM().putInit(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getBFM().putInit(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); } @Override - public Map getFacetStore() { - return facetStore; + public BaseFacetMap getBFM() { + return bfm; } public static void forEach(Consumer consumer) { diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T07PartPlanIt.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T07PartPlanIt.java index bdd271bb..5fe8d09d 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T07PartPlanIt.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T07PartPlanIt.java @@ -2,13 +2,13 @@ package love.distributedrebirth.numberxd.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.numberxd.base2t.facet.BasePart; import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt1; /** @@ -28,7 +28,7 @@ public enum T07PartPlanIt implements BasePart,BasePartAlt1 { ; public static int LENGTH() { return values().length; }; - private final Map facetStore = new HashMap<>(); + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); private static final String ALT_1_NAME = "Fallen sign"; private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Classical_planet#Western_astrology"; private static final Map TONE_MAP = Collections.unmodifiableMap( @@ -37,18 +37,18 @@ public enum T07PartPlanIt implements BasePart,BasePartAlt1 { Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); private T07PartPlanIt(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); + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getBFM().putInit(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getBFM().putInit(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); } @Override - public Map getFacetStore() { - return facetStore; + public BaseFacetMap getBFM() { + return bfm; } public static void forEach(Consumer consumer) { diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T08PartOctal.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T08PartOctal.java index 1ec3d928..5e33508a 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T08PartOctal.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T08PartOctal.java @@ -2,13 +2,13 @@ package love.distributedrebirth.numberxd.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.numberxd.base2t.facet.BasePart; import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt2; import love.distributedrebirth.numberxd.base2t.facet.BasePartSplit8; @@ -32,7 +32,7 @@ public enum T08PartOctal implements BasePart,BasePartAlt2,BasePartSplit8 { public static int LENGTH() { return values().length; }; public static int BIT_COUNT = 3; private static final byte BITMASK = 0x07; - private final Map facetStore = new HashMap<>(); + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); 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"; @@ -44,22 +44,22 @@ public enum T08PartOctal implements BasePart,BasePartAlt2,BasePartSplit8 { Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); 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); + this.getBFM().putInit(BaseFacetKey.ID_TONE, identifierTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, identifierLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getBFM().putInit(BaseFacetKey.SHIFT_BITS, Integer.valueOf(shiftBits)); + this.getBFM().putInit(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getBFM().putInit(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); + this.getBFM().putInit(BaseFacetKey.ALT_2_VALUE, alt2Value); + this.getBFM().putInit(BaseFacetKey.ALT_2_NAME, ALT_2_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_2_WIKI, ALT_2_WIKI); } @Override - public Map getFacetStore() { - return facetStore; + public BaseFacetMap getBFM() { + return bfm; } public static T08PartOctal indexOf(T08PartOctal group, int value) { diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T12PartUncial.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T12PartUncial.java index 365ffd91..cfb1bbfe 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T12PartUncial.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T12PartUncial.java @@ -2,13 +2,13 @@ package love.distributedrebirth.numberxd.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.numberxd.base2t.facet.BasePart; import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt1; /** @@ -33,7 +33,7 @@ public enum T12PartUncial implements BasePart,BasePartAlt1 { ; public static int LENGTH() { return values().length; }; - private final Map facetStore = new HashMap<>(); + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); 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( @@ -42,18 +42,18 @@ public enum T12PartUncial implements BasePart,BasePartAlt1 { Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); 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); + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getBFM().putInit(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getBFM().putInit(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); } @Override - public Map getFacetStore() { - return facetStore; + public BaseFacetMap getBFM() { + return bfm; } public static void forEach(Consumer consumer) { diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T16PartHex.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T16PartHex.java index 26b05761..507e5ce6 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T16PartHex.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T16PartHex.java @@ -2,13 +2,13 @@ package love.distributedrebirth.numberxd.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.numberxd.base2t.facet.BasePart; import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt1; import love.distributedrebirth.numberxd.base2t.facet.BasePartSplit16; @@ -38,7 +38,7 @@ public enum T16PartHex implements BasePart,BasePartAlt1,BasePartSplit16 { ; public static int LENGTH() { return values().length; }; - private final Map facetStore = new HashMap<>(); + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); 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( @@ -47,18 +47,18 @@ public enum T16PartHex implements BasePart,BasePartAlt1,BasePartSplit16 { Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); 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); + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getBFM().putInit(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getBFM().putInit(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); } @Override - public Map getFacetStore() { - return facetStore; + public BaseFacetMap getBFM() { + return bfm; } public static void forEach(Consumer consumer) { diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T20PartScore.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T20PartScore.java index ed02be66..f1ea982c 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T20PartScore.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T20PartScore.java @@ -2,13 +2,13 @@ package love.distributedrebirth.numberxd.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.numberxd.base2t.facet.BasePart; import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt3; /** @@ -41,7 +41,7 @@ public enum T20PartScore implements BasePart,BasePartAlt3 { ; public static int LENGTH() { return values().length; }; - private final Map facetStore = new HashMap<>(); + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); private static final String ALT_1_NAME = "Vigesimal"; private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Vigesimal#Places"; private static final String ALT_2_NAME = "Vigesimal Alternative"; @@ -57,24 +57,24 @@ public enum T20PartScore implements BasePart,BasePartAlt3 { private T20PartScore(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value, String alt2Value, String alt3Value) { - 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); - 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); - this.getFacetStore().put(BaseFacetKey.ALT_3_VALUE, alt3Value); - this.getFacetStore().put(BaseFacetKey.ALT_3_NAME, ALT_3_NAME); - this.getFacetStore().put(BaseFacetKey.ALT_3_WIKI, ALT_3_WIKI); + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); + this.getBFM().putInit(BaseFacetKey.ALT_1_VALUE, alt1Value); + this.getBFM().putInit(BaseFacetKey.ALT_1_NAME, ALT_1_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI); + this.getBFM().putInit(BaseFacetKey.ALT_2_VALUE, alt2Value); + this.getBFM().putInit(BaseFacetKey.ALT_2_NAME, ALT_2_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_2_WIKI, ALT_2_WIKI); + this.getBFM().putInit(BaseFacetKey.ALT_3_VALUE, alt3Value); + this.getBFM().putInit(BaseFacetKey.ALT_3_NAME, ALT_3_NAME); + this.getBFM().putInit(BaseFacetKey.ALT_3_WIKI, ALT_3_WIKI); } @Override - public Map getFacetStore() { - return facetStore; + public BaseFacetMap getBFM() { + return bfm; } public static void forEach(Consumer consumer) { diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T60Sexagesimal.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T60Sexagesimal.java index a79dd0ff..fdaf7670 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T60Sexagesimal.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T60Sexagesimal.java @@ -2,13 +2,13 @@ package love.distributedrebirth.numberxd.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.numberxd.base2t.facet.BasePart; import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; /** * The distribution by 60. @@ -83,22 +83,22 @@ public enum T60Sexagesimal implements BasePart { ; public static int LENGTH() { return values().length; }; - private final Map facetStore = new HashMap<>(); + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); 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 T60Sexagesimal(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); + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); } @Override - public Map getFacetStore() { - return facetStore; + public BaseFacetMap getBFM() { + return bfm; } public static void forEach(Consumer consumer) { diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BaseFacetMap.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BaseFacetMap.java new file mode 100644 index 00000000..9d4bbe20 --- /dev/null +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BaseFacetMap.java @@ -0,0 +1,43 @@ +package love.distributedrebirth.numberxd.base2t.facet; + +import java.util.HashMap; +import java.util.Map; + +public interface BaseFacetMap { + + Object putInit(BaseFacetKey key, Object value); + + Object get(BaseFacetKey key); + + default String getString(BaseFacetKey key) { + return String.class.cast(get(key)); + } + + default Integer getInteger(BaseFacetKey key) { + return Integer.class.cast(get(key)); + } + + default Long getLong(BaseFacetKey key) { + return Long.class.cast(get(key)); + } + + default Boolean getBoolean(BaseFacetKey key) { + return Boolean.class.cast(get(key)); + } + + static BaseFacetMap newInstance() { + return new BaseFacetMap() { + final Map initMap = new HashMap<>(); + + @Override + public Object get(BaseFacetKey key) { + return initMap.get(key); + } + + @Override + public Object putInit(BaseFacetKey key, Object value) { + return initMap.put(key, value); + } + }; + } +} diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BaseFacetStore.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BaseFacetStore.java index 8266b537..3f6027b1 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BaseFacetStore.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BaseFacetStore.java @@ -1,7 +1,5 @@ package love.distributedrebirth.numberxd.base2t.facet; -import java.util.Map; - /** * * @@ -9,5 +7,5 @@ import java.util.Map; */ public interface BaseFacetStore { - Map getFacetStore(); + BaseFacetMap getBFM(); } diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePart.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePart.java index d38fbba4..b0de6124 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePart.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePart.java @@ -10,18 +10,18 @@ public interface BasePart extends BaseFacetStore { int ordinal(); default String getIdentifierTone() { - return (String)getFacetStore().get(BaseFacetKey.ID_TONE); + return getBFM().getString(BaseFacetKey.ID_TONE); } default String getIdentifierLetter() { - return (String)getFacetStore().get(BaseFacetKey.ID_LETTER); + return getBFM().getString(BaseFacetKey.ID_LETTER); } default String getChinaKey() { - return (String)getFacetStore().get(BaseFacetKey.CHINA_KEY); + return getBFM().getString(BaseFacetKey.CHINA_KEY); } default String getChinaValue() { - return (String)getFacetStore().get(BaseFacetKey.CHINA_VALUE); + return getBFM().getString(BaseFacetKey.CHINA_VALUE); } } diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt1.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt1.java index 1befe924..c155e04b 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt1.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt1.java @@ -8,14 +8,14 @@ package love.distributedrebirth.numberxd.base2t.facet; public interface BasePartAlt1 extends BasePart { default String getAlt1Value() { - return (String)getFacetStore().get(BaseFacetKey.ALT_1_VALUE); + return getBFM().getString(BaseFacetKey.ALT_1_VALUE); } default String getAlt1Name() { - return (String)getFacetStore().get(BaseFacetKey.ALT_1_NAME); + return getBFM().getString(BaseFacetKey.ALT_1_NAME); } default String getAlt1Wiki() { - return (String)getFacetStore().get(BaseFacetKey.ALT_1_WIKI); + return getBFM().getString(BaseFacetKey.ALT_1_WIKI); } } diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt2.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt2.java index 8e602f8d..b13d0059 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt2.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt2.java @@ -8,14 +8,14 @@ package love.distributedrebirth.numberxd.base2t.facet; public interface BasePartAlt2 extends BasePartAlt1 { default String getAlt2Value() { - return (String)getFacetStore().get(BaseFacetKey.ALT_2_VALUE); + return getBFM().getString(BaseFacetKey.ALT_2_VALUE); } default String getAlt2Name() { - return (String)getFacetStore().get(BaseFacetKey.ALT_2_NAME); + return getBFM().getString(BaseFacetKey.ALT_2_NAME); } default String getAlt2Wiki() { - return (String)getFacetStore().get(BaseFacetKey.ALT_2_WIKI); + return getBFM().getString(BaseFacetKey.ALT_2_WIKI); } } diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt3.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt3.java index db3b186f..25900eb6 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt3.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt3.java @@ -8,14 +8,14 @@ package love.distributedrebirth.numberxd.base2t.facet; public interface BasePartAlt3 extends BasePartAlt2 { default String getAlt3Value() { - return (String)getFacetStore().get(BaseFacetKey.ALT_3_VALUE); + return getBFM().getString(BaseFacetKey.ALT_3_VALUE); } default String getAlt3Name() { - return (String)getFacetStore().get(BaseFacetKey.ALT_3_NAME); + return getBFM().getString(BaseFacetKey.ALT_3_NAME); } default String getAlt3Wiki() { - return (String)getFacetStore().get(BaseFacetKey.ALT_3_WIKI); + return getBFM().getString(BaseFacetKey.ALT_3_WIKI); } } diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt4.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt4.java index a0dee41c..fe1d80c4 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt4.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartAlt4.java @@ -8,14 +8,14 @@ package love.distributedrebirth.numberxd.base2t.facet; public interface BasePartAlt4 extends BasePartAlt3 { default String getAlt4Value() { - return (String)getFacetStore().get(BaseFacetKey.ALT_4_VALUE); + return getBFM().getString(BaseFacetKey.ALT_4_VALUE); } default String getAlt4Name() { - return (String)getFacetStore().get(BaseFacetKey.ALT_4_NAME); + return getBFM().getString(BaseFacetKey.ALT_4_NAME); } default String getAlt4Wiki() { - return (String)getFacetStore().get(BaseFacetKey.ALT_4_WIKI); + return getBFM().getString(BaseFacetKey.ALT_4_WIKI); } } diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartShiftBits.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartShiftBits.java index 85b0618b..f64b1d82 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartShiftBits.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePartShiftBits.java @@ -8,6 +8,6 @@ package love.distributedrebirth.numberxd.base2t.facet; public interface BasePartShiftBits extends BasePart { default Integer getShiftBits() { - return (Integer)getFacetStore().get(BaseFacetKey.SHIFT_BITS); + return getBFM().getInteger(BaseFacetKey.SHIFT_BITS); } }