diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/lang/ObjectToHuman.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/lang/ObjectToHuman.java new file mode 100644 index 00000000..0d2693f1 --- /dev/null +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/lang/ObjectToHuman.java @@ -0,0 +1,21 @@ +package love.distributedrebirth.bassboon.jpp.lang; + +import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注; + +/** + * Mark objects which need a English latin1 human output. + * + * Human output can't be defined. + */ +@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天") +public interface ObjectToHuman { + + // it looks like this was JMX in java version 1.0 + String toString(); // the biggest mistake in java + // thus for who in what format and which details... + + // Every computer needs brahmi support on strings + default StringUnicode toStringUnicode() { + return StringUnicode.valueOf(toString()); + } +} diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/lang/StringTypeConst.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/lang/StringTypeConst.java index a255d3e7..9c1823c4 100644 --- a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/lang/StringTypeConst.java +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/lang/StringTypeConst.java @@ -11,11 +11,11 @@ import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注; * String without any char or byte methods. */ @BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天") -public interface StringTypeConst> extends Comparable, Iterable /*, CharSequence */ { - - // ---- Local +public interface StringTypeConst> extends Comparable, Iterable, ObjectToHuman /*, CharSequence */ { - String toString(); + //int[] values(); + + // ---- Local default long lengthBytes() { return toString().length() + toString().length(); diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/ArrayListᴿᵂ.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/ArrayListᴿᵂ.java index 05f87183..b8d49525 100644 --- a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/ArrayListᴿᵂ.java +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/ArrayListᴿᵂ.java @@ -5,6 +5,9 @@ import java.util.Comparator; import java.util.Iterator; import java.util.List; +import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注; + +@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天") public class ArrayListᴿᵂ implements Listᵂʳ,Iterable { private final List data; @@ -30,6 +33,11 @@ public class ArrayListᴿᵂ implements Listᵂʳ,Iterable { return Iteratorᴿᵈ.wrapᴼᶠ(iterator()); } + @Override + public Iteratorᵂʳ iteratorᵂʳ() { + return Iteratorᵂʳ.wrapᴼᶠ(iterator()); + } + @Override public boolean addᵂʳ(E value) { return data.add(value); diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᴿᵈ.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᴿᵈ.java index 32368100..85ae2f75 100644 --- a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᴿᵈ.java +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᴿᵈ.java @@ -6,7 +6,6 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注; -import love.distributedrebirth.bassboon.jpp.lang.Iterableᴿᵈ; @BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天") public interface Collectionᴿᵈ extends Iterableᴿᵈ { diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᵂʳ.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᵂʳ.java index c2fe1cb5..b5a55e03 100644 --- a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᵂʳ.java +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᵂʳ.java @@ -8,6 +8,8 @@ import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注; @BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天") public interface Collectionᵂʳ extends Collectionᴿᵈ, Appenderᵂʳ { + Iteratorᵂʳ iteratorᵂʳ(); + boolean removeᵂʳ(Object o); default void clearᵂʳ() { @@ -26,13 +28,15 @@ public interface Collectionᵂʳ extends Collectionᴿᵈ, Appenderᵂʳ filter) { - Collectionᴿᵈ delete = new Collectionᴿᵈ<>() { - @Override - public Iteratorᴿᵈ iteratorᴿᵈ() { - return Iteratorᴿᵈ.wrapᴼᶠ(streamᴿᵈ().filter(filter).collect(Collectors.toList()).iterator()); + boolean result = false; + Iteratorᵂʳ iterator = iteratorᵂʳ(); + while (iterator.hasNextᴿᵈ()) { + if (filter.test(iterator.nextᴿᵈ())) { + iterator.removeᵂʳ(); + result = true; } - }; - return removeAll(delete); + } + return result; } default boolean retainAll(Collectionᴿᵈ set) { diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/lang/Iterableᴿᵈ.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Iterableᴿᵈ.java similarity index 83% rename from gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/lang/Iterableᴿᵈ.java rename to gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Iterableᴿᵈ.java index 84223e88..b6277068 100644 --- a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/lang/Iterableᴿᵈ.java +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Iterableᴿᵈ.java @@ -1,11 +1,10 @@ -package love.distributedrebirth.bassboon.jpp.lang; +package love.distributedrebirth.bassboon.jpp.util; import java.util.Spliterator; import java.util.Spliterators; import java.util.function.Consumer; import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注; -import love.distributedrebirth.bassboon.jpp.util.Iteratorᴿᵈ; @BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天") public interface Iterableᴿᵈ { diff --git a/gdxapp4d-lib-bassboonyd/src/test/java/love/distributedrebirth/bassboon/jpp/lang/ObjectToHumanTest.java b/gdxapp4d-lib-bassboonyd/src/test/java/love/distributedrebirth/bassboon/jpp/lang/ObjectToHumanTest.java new file mode 100644 index 00000000..c2d5ceb0 --- /dev/null +++ b/gdxapp4d-lib-bassboonyd/src/test/java/love/distributedrebirth/bassboon/jpp/lang/ObjectToHumanTest.java @@ -0,0 +1,39 @@ +package love.distributedrebirth.bassboon.jpp.lang; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注; + +@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天") +public class ObjectToHumanTest { + + @Test + public void testObjectToHuman() { + class HumanObjectSimple implements ObjectToHuman { + @Override + public String toString() { + return "ik probeer mens te zijn..."; + } + } + HumanObjectSimple object = new HumanObjectSimple(); + Assertions.assertTrue(object != null); + Assertions.assertTrue(object.toString() != null); + Assertions.assertTrue(object.toStringUnicode() != null); + Assertions.assertEquals(object.toString().length(), object.toStringUnicode().lengthChars()); + Assertions.assertTrue(object.toString().contains("mens")); + Assertions.assertTrue(object.toStringUnicode().contains(StringUnicode.valueOf("mens"))); + } + + @Test + public void testObjectToObject2() { + StringUnicode str = new StringUnicode("0123456789"); + for (int i=0;i<10;i++) { + str = str.toStringUnicode(); + } + Assertions.assertTrue(str != null); + Assertions.assertEquals(20, str.toStringUnicode().lengthBytes()); + Assertions.assertEquals(10, str.toStringUnicode().lengthChars()); + Assertions.assertEquals(10, str.toStringUnicode().lengthCodePoints()); + } +}