added string proxy

This commit is contained in:
Willem Cazander 2022-10-21 23:16:52 +02:00
parent 0ecc63e44c
commit d26afc79c3
3 changed files with 276 additions and 3 deletions

View file

@ -3,9 +3,7 @@ package love.distributedrebirth.bassboon.jpp.lang;
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public interface StringDEC6B {
String toString();
public interface StringDEC6B extends StringProxy {
enum BasicAscii {
UNICODE;

View file

@ -0,0 +1,205 @@
package love.distributedrebirth.bassboon.jpp.lang;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.Locale;
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public interface StringProxy {
String toString();
default char charAt(int index) {
return toString().charAt(index);
}
default int codePointAt(int index) {
return toString().codePointAt(index);
}
default int codePointBefore(int index) {
return toString().codePointBefore(index);
}
default int codePointCount(int beginIndex, int endIndex) {
return toString().codePointCount(beginIndex, endIndex);
}
default int compareTo(String anotherString) {
return toString().compareTo(anotherString);
}
default int compareToIgnoreCase(String str) {
return toString().compareToIgnoreCase(str);
}
default String concat(String str) {
return toString().concat(str);
}
default boolean contains(CharSequence s) {
return toString().contains(s);
}
default boolean contentEquals(CharSequence cs) {
return toString().contentEquals(cs);
}
default boolean contentEquals(StringBuffer sb) {
return toString().contentEquals(sb);
}
default boolean endsWith(String suffix) {
return toString().endsWith(suffix);
}
default boolean equalsIgnoreCase(String anotherString) {
return toString().equalsIgnoreCase(anotherString);
}
default byte[] getBytes() {
return toString().getBytes();
}
default byte[] getBytes(Charset charset) {
return toString().getBytes(charset);
}
default byte[] getBytes(String charsetName) throws UnsupportedEncodingException {
return toString().getBytes(charsetName);
}
default void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) {
toString().getChars(srcBegin, srcEnd, dst, dstBegin);
}
default int indexOf(int ch) {
return toString().indexOf(ch);
}
default int indexOf(int ch, int fromIndex) {
return toString().indexOf(ch, fromIndex);
}
default int indexOf(String str) {
return toString().indexOf(str);
}
default int indexOf(String str, int fromIndex) {
return toString().indexOf(str, fromIndex);
}
default String intern() {
return toString().intern();
}
default boolean isEmpty() {
return toString().isEmpty();
}
default int lastIndexOf(int ch) {
return toString().lastIndexOf(ch);
}
default int lastIndexOf(int ch, int fromIndex) {
return toString().lastIndexOf(ch, fromIndex);
}
default int lastIndexOf(String str) {
return toString().lastIndexOf(str);
}
default int lastIndexOf(String str, int fromIndex) {
return toString().lastIndexOf(str, fromIndex);
}
default int length() {
return toString().length();
}
default boolean matches(String regex) {
return toString().matches(regex);
}
default int offsetByCodePoints(int index, int codePointOffset) {
return toString().offsetByCodePoints(index, codePointOffset);
}
default boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) {
return toString().regionMatches(ignoreCase, toffset, other, ooffset, len);
}
default boolean regionMatches(int toffset, String other, int ooffset, int len) {
return toString().regionMatches(toffset, other, ooffset, len);
}
default String replace(char oldChar, char newChar) {
return toString().replace(oldChar, newChar);
}
default String replace(CharSequence target, CharSequence replacement) {
return toString().replace(target, replacement);
}
default String replaceAll(String regex, String replacement) {
return toString().replaceAll(regex, replacement);
}
default String replaceFirst(String regex, String replacement) {
return toString().replaceFirst(regex, replacement);
}
default String[] split(String regex) {
return toString().split(regex);
}
default String[] split(String regex, int limit) {
return toString().split(regex, limit);
}
default boolean startsWith(String prefix) {
return toString().startsWith(prefix);
}
default boolean startsWith(String prefix, int toffset) {
return toString().startsWith(prefix, toffset);
}
default CharSequence subSequence(int beginIndex, int endIndex) {
return toString().subSequence(beginIndex, endIndex);
}
default String substring(int beginIndex) {
return toString().substring(beginIndex);
}
default String substring(int beginIndex, int endIndex) {
return toString().substring(beginIndex, endIndex);
}
default char[] toCharArray() {
return toString().toCharArray();
}
default String toLowerCase() {
return toString().toLowerCase();
}
default String toLowerCase(Locale locale) {
return toString().toLowerCase(locale);
}
default String toUpperCase() {
return toString().toUpperCase();
}
default String toUpperCase(Locale locale) {
return toString().toUpperCase(locale);
}
default String trim() {
return toString().trim();
}
}

View file

@ -0,0 +1,70 @@
package love.distributedrebirth.bassboon.jpp.lang;
import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注;
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public interface StringTweet extends StringProxy {
interface Length035 extends StringTweet {
}
interface Length070 extends StringTweet {
}
interface Length140 extends StringTweet {
}
interface Length280 extends StringTweet {
}
static StringTweet tweetᴺᵉʷ(String text, Class<? extends StringTweet> tweetType) {
if (text == null) {
throw new NullPointerException("Can't create null tweet.");
}
if (tweetType == null) {
throw new NullPointerException("Can't create tweet with null type.");
}
if (Length035.class.equals(tweetType)) {
if (text.codePoints().count() > 35) {
throw new IllegalArgumentException("Tweet code points lenght is larger than: 35");
}
return new Length035() {
@Override
public String toString() {
return text;
}
};
}
if (Length070.class.equals(tweetType)) {
if (text.codePoints().count() > 70) {
throw new IllegalArgumentException("Tweet code points lenght is larger than: 70");
}
return new Length070() {
@Override
public String toString() {
return text;
}
};
}
if (Length140.class.equals(tweetType)) {
if (text.codePoints().count() > 35) {
throw new IllegalArgumentException("Tweet code points lenght is larger than: 140");
}
return new Length140() {
@Override
public String toString() {
return text;
}
};
}
if (Length280.class.equals(tweetType)) {
if (text.codePoints().count() > 280) {
throw new IllegalArgumentException("Tweet code points lenght is larger than: 280");
}
return new Length280() {
@Override
public String toString() {
return text;
}
};
}
throw new IllegalArgumentException("Can't create tweet with unknown type: "+tweetType);
}
}