Replacement for java.lang.String is needed

This commit is contained in:
Willem Cazander 2022-10-24 03:57:39 +02:00
parent be643fa4bb
commit ac1e1e5c43
27 changed files with 692 additions and 390 deletions

View file

@ -4,88 +4,89 @@ import java.util.List;
import java.util.Map;
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
import love.distributedrebirth.bassboon.jpp.lang.StringGhostKey;
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public interface BãßBȍőnCoffinGhost {
Object GHOST_OBJ(GhostKey鬼鑰匙 key);
Object GHOST_OBJ(StringGhostKey key);
@SuppressWarnings("unchecked")
default <Y> Y GHOST_OBJ(GhostKey鬼鑰匙 key, Class<Y> type) {
default <Y> Y GHOST_OBJ(StringGhostKey key, Class<Y> type) {
return (Y) GHOST_OBJ(key);
}
default String GHOST_STR(GhostKey鬼鑰匙 key) {
default String GHOST_STR(StringGhostKey key) {
return String.class.cast(GHOST_OBJ(key));
}
default Short GHOST_SHORT(GhostKey鬼鑰匙 key) {
default Short GHOST_SHORT(StringGhostKey key) {
return Short.class.cast(GHOST_OBJ(key));
}
default Character GHOST_CHAR(GhostKey鬼鑰匙 key) {
default Character GHOST_CHAR(StringGhostKey key) {
return Character.class.cast(GHOST_OBJ(key));
}
default Integer GHOST_INT(GhostKey鬼鑰匙 key) {
default Integer GHOST_INT(StringGhostKey key) {
return Integer.class.cast(GHOST_OBJ(key));
}
default Long GHOST_LONG(GhostKey鬼鑰匙 key) {
default Long GHOST_LONG(StringGhostKey key) {
return Long.class.cast(GHOST_OBJ(key));
}
default Boolean GHOST_BOOL(GhostKey鬼鑰匙 key) {
default Boolean GHOST_BOOL(StringGhostKey key) {
return Boolean.class.cast(GHOST_OBJ(key));
}
default Float GHOST_FLOAT(GhostKey鬼鑰匙 key) {
default Float GHOST_FLOAT(StringGhostKey key) {
return Float.class.cast(GHOST_OBJ(key));
}
default Double GHOST_DOUBLE(GhostKey鬼鑰匙 key) {
default Double GHOST_DOUBLE(StringGhostKey key) {
return Double.class.cast(GHOST_OBJ(key));
}
@SuppressWarnings("unchecked")
default Map<String,Object> GHOST_MAP_OBJ(GhostKey鬼鑰匙 key) {
default Map<String,Object> GHOST_MAP_OBJ(StringGhostKey key) {
return Map.class.cast(GHOST_OBJ(key));
}
default Object GHOST_MAP_OBJ_VALUE(GhostKey鬼鑰匙 key, String mapKey) {
default Object GHOST_MAP_OBJ_VALUE(StringGhostKey key, String mapKey) {
return GHOST_MAP_OBJ(key).get(mapKey);
}
@SuppressWarnings("unchecked")
default Map<String,String> GHOST_MAP_STR(GhostKey鬼鑰匙 key) {
default Map<String,String> GHOST_MAP_STR(StringGhostKey key) {
return Map.class.cast(GHOST_OBJ(key));
}
default String GHOST_MAP_STR_VALUE(GhostKey鬼鑰匙 key, String mapKey) {
default String GHOST_MAP_STR_VALUE(StringGhostKey key, String mapKey) {
return GHOST_MAP_STR(key).get(mapKey);
}
@SuppressWarnings("unchecked")
default Map<String,Integer> GHOST_MAP_INT(GhostKey鬼鑰匙 key) {
default Map<String,Integer> GHOST_MAP_INT(StringGhostKey key) {
return Map.class.cast(GHOST_OBJ(key));
}
default Integer GHOST_MAP_INT_VALUE(GhostKey鬼鑰匙 key, String mapKey) {
default Integer GHOST_MAP_INT_VALUE(StringGhostKey key, String mapKey) {
return GHOST_MAP_INT(key).get(mapKey);
}
@SuppressWarnings("unchecked")
default List<Object> GHOST_LIST_OBJ(GhostKey鬼鑰匙 key) {
default List<Object> GHOST_LIST_OBJ(StringGhostKey key) {
return List.class.cast(GHOST_OBJ(key));
}
@SuppressWarnings("unchecked")
default List<String> GHOST_LIST_STR(GhostKey鬼鑰匙 key) {
default List<String> GHOST_LIST_STR(StringGhostKey key) {
return List.class.cast(GHOST_OBJ(key));
}
@SuppressWarnings("unchecked")
default List<Integer> GHOST_LIST_INT(GhostKey鬼鑰匙 key) {
default List<Integer> GHOST_LIST_INT(StringGhostKey key) {
return List.class.cast(GHOST_OBJ(key));
}
}

View file

@ -4,17 +4,18 @@ import java.util.ArrayList;
import java.util.HashMap;
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
import love.distributedrebirth.bassboon.jpp.lang.StringGhostKey;
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public interface BãßBȍőnCoffinGhostSpell extends BãßBȍőnCoffinGhost {
Object PUT_GHOST(GhostKey鬼鑰匙 key, Object value);
Object PUT_GHOST(StringGhostKey key, Object value);
default void PUT_GHOST_MAP(GhostKey鬼鑰匙 key) {
default void PUT_GHOST_MAP(StringGhostKey key) {
PUT_GHOST(key, new HashMap<>());
}
default void PUT_GHOST_LIST(GhostKey鬼鑰匙 key) {
default void PUT_GHOST_LIST(StringGhostKey key) {
PUT_GHOST(key, new ArrayList<>());
}

View file

@ -7,6 +7,7 @@ import java.util.Map;
import java.util.function.Function;
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
import love.distributedrebirth.bassboon.jpp.lang.StringGhostKey;
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public interface BãßBȍőnCoffinGhostSpellLock extends BãßBȍőnCoffinGhostSpell {
@ -18,9 +19,9 @@ public interface BãßBȍőnCoffinGhostSpellLock extends BãßBȍőnCoffinGhostS
}
static BãßBȍőnCoffinGhostSpellLock instanceᴺᵉʷ() {
Function<Map<GhostKey鬼鑰匙,Object>,BãßBȍőnCoffinGhost> keyMaker = v -> {
Map<GhostKey鬼鑰匙,Object> summonedGhosts = new HashMap<>(v);
for (GhostKey鬼鑰匙 entity:v.keySet()) {
Function<Map<StringGhostKey,Object>,BãßBȍőnCoffinGhost> keyMaker = v -> {
Map<StringGhostKey,Object> summonedGhosts = new HashMap<>(v);
for (StringGhostKey entity:v.keySet()) {
Object spirit = summonedGhosts.get(entity);
if (spirit instanceof List) {
summonedGhosts.put(entity, Collections.unmodifiableList((List<?>) spirit));
@ -31,13 +32,13 @@ public interface BãßBȍőnCoffinGhostSpellLock extends BãßBȍőnCoffinGhostS
}
return new BãßBȍőnCoffinGhost() {
@Override
public Object GHOST_OBJ(GhostKey鬼鑰匙 key) {
public Object GHOST_OBJ(StringGhostKey key) {
return summonedGhosts.get(key);
}
};
};
return new BãßBȍőnCoffinGhostSpellLock() {
private final Map<GhostKey鬼鑰匙,Object> ouijaBoard = new HashMap<>();
private final Map<StringGhostKey,Object> ouijaBoard = new HashMap<>();
@Override
public BãßBȍőnCoffinGhost LOCK() {
@ -45,12 +46,12 @@ public interface BãßBȍőnCoffinGhostSpellLock extends BãßBȍőnCoffinGhostS
}
@Override
public Object GHOST_OBJ(GhostKey鬼鑰匙 key) {
public Object GHOST_OBJ(StringGhostKey key) {
return ouijaBoard.get(key);
}
@Override
public Object PUT_GHOST(GhostKey鬼鑰匙 key, Object value) {
public Object PUT_GHOST(StringGhostKey key, Object value) {
return ouijaBoard.put(key, value);
}
};

View file

@ -1,50 +0,0 @@
package love.distributedrebirth.bassboon.death;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import love.distributedrebirth.bassboon.Bãß;
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
import love.distributedrebirth.bassboon.jpp.lang.StringDEC6B;
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public interface GhostKey鬼鑰匙 extends StringDEC6B {
enum 𓉡 {
ײןןזןןןזזזןײ;
private final Map<Class<?>, AtomicInteger> 精神龸鑰匙 = Collections.synchronizedMap(new HashMap<>());
private final int 開始龸價值龸阿瑪利亞 = 0xB00BBABE - Bãß.ℭỗᶇṧⱦᶏꬼȶʂ.INT_ONE;
}
static GhostKey鬼鑰匙 asciiᴳʰᵒˢᵗ() {
Class<?> parentClass = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass();
AtomicInteger cnt = 𓉡.ײןןזןןןזזזןײ.精神龸鑰匙.get(parentClass);
if (cnt == null) {
cnt = new AtomicInteger(𓉡.ײןןזןןןזזזןײ.開始龸價值龸阿瑪利亞);
𓉡.ײןןזןןןזזזןײ.精神龸鑰匙.put(parentClass, cnt);
}
int fieldNumber = cnt.incrementAndGet();
StringBuilder buf = new StringBuilder();
buf.append(Integer.toHexString(parentClass.hashCode()).toUpperCase()); // our callers are named Ꝑŕḯṿª so use hashCode
buf.append(StringDEC6B.BasicAscii.UNDERSCORE);
buf.append(Integer.toHexString(fieldNumber).toUpperCase());
return asciiᴺᵉʷ(buf.toString());
}
static GhostKey鬼鑰匙 asciiᴺᵉʷ(String text) {
for (int i=0;i<text.length();i++) {
if (!BasicAscii.UNICODE.isValidKey(text.charAt(i))) {
throw new IllegalArgumentException("Invalid character: "+text.charAt(i));
}
}
return new GhostKey鬼鑰匙() {
@Override
public String toString() {
return text;
}
};
}
}