Added toString interface
This commit is contained in:
parent
107435ec13
commit
be3f1a9476
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,11 +11,11 @@ import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
|
||||||
* String without any char or byte methods.
|
* String without any char or byte methods.
|
||||||
*/
|
*/
|
||||||
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||||
public interface StringTypeConst<T extends StringTypeConst<T>> extends Comparable<T>, Iterable<Integer> /*, CharSequence */ {
|
public interface StringTypeConst<T extends StringTypeConst<T>> extends Comparable<T>, Iterable<Integer>, ObjectToHuman /*, CharSequence */ {
|
||||||
|
|
||||||
// ---- Local
|
|
||||||
|
|
||||||
String toString();
|
//int[] values();
|
||||||
|
|
||||||
|
// ---- Local
|
||||||
|
|
||||||
default long lengthBytes() {
|
default long lengthBytes() {
|
||||||
return toString().length() + toString().length();
|
return toString().length() + toString().length();
|
||||||
|
|
|
@ -5,6 +5,9 @@ import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
|
||||||
|
|
||||||
|
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||||
public class ArrayListᴿᵂ<E> implements Listᵂʳ<E>,Iterable<E> {
|
public class ArrayListᴿᵂ<E> implements Listᵂʳ<E>,Iterable<E> {
|
||||||
|
|
||||||
private final List<E> data;
|
private final List<E> data;
|
||||||
|
@ -30,6 +33,11 @@ public class ArrayListᴿᵂ<E> implements Listᵂʳ<E>,Iterable<E> {
|
||||||
return Iteratorᴿᵈ.wrapᴼᶠ(iterator());
|
return Iteratorᴿᵈ.wrapᴼᶠ(iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iteratorᵂʳ<E> iteratorᵂʳ() {
|
||||||
|
return Iteratorᵂʳ.wrapᴼᶠ(iterator());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addᵂʳ(E value) {
|
public boolean addᵂʳ(E value) {
|
||||||
return data.add(value);
|
return data.add(value);
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.util.stream.Stream;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
|
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
|
||||||
import love.distributedrebirth.bassboon.jpp.lang.Iterableᴿᵈ;
|
|
||||||
|
|
||||||
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||||
public interface Collectionᴿᵈ<E> extends Iterableᴿᵈ<E> {
|
public interface Collectionᴿᵈ<E> extends Iterableᴿᵈ<E> {
|
||||||
|
|
|
@ -8,6 +8,8 @@ import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
|
||||||
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||||
public interface Collectionᵂʳ<E> extends Collectionᴿᵈ<E>, Appenderᵂʳ<E> {
|
public interface Collectionᵂʳ<E> extends Collectionᴿᵈ<E>, Appenderᵂʳ<E> {
|
||||||
|
|
||||||
|
Iteratorᵂʳ<E> iteratorᵂʳ();
|
||||||
|
|
||||||
boolean removeᵂʳ(Object o);
|
boolean removeᵂʳ(Object o);
|
||||||
|
|
||||||
default void clearᵂʳ() {
|
default void clearᵂʳ() {
|
||||||
|
@ -26,13 +28,15 @@ public interface Collectionᵂʳ<E> extends Collectionᴿᵈ<E>, Appenderᵂʳ<E
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean removeIf(Predicate<? super E> filter) {
|
default boolean removeIf(Predicate<? super E> filter) {
|
||||||
Collectionᴿᵈ<E> delete = new Collectionᴿᵈ<>() {
|
boolean result = false;
|
||||||
@Override
|
Iteratorᵂʳ<E> iterator = iteratorᵂʳ();
|
||||||
public Iteratorᴿᵈ<E> iteratorᴿᵈ() {
|
while (iterator.hasNextᴿᵈ()) {
|
||||||
return Iteratorᴿᵈ.wrapᴼᶠ(streamᴿᵈ().filter(filter).collect(Collectors.toList()).iterator());
|
if (filter.test(iterator.nextᴿᵈ())) {
|
||||||
|
iterator.removeᵂʳ();
|
||||||
|
result = true;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
return removeAll(delete);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean retainAll(Collectionᴿᵈ<?> set) {
|
default boolean retainAll(Collectionᴿᵈ<?> set) {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package love.distributedrebirth.bassboon.jpp.lang;
|
package love.distributedrebirth.bassboon.jpp.util;
|
||||||
|
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
import java.util.Spliterators;
|
import java.util.Spliterators;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
|
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
|
||||||
import love.distributedrebirth.bassboon.jpp.util.Iteratorᴿᵈ;
|
|
||||||
|
|
||||||
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||||
public interface Iterableᴿᵈ<E> {
|
public interface Iterableᴿᵈ<E> {
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue