gdxapp4d/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/DefaultEnumSetʸᴰ.java

76 lines
2.3 KiB
Java
Raw Normal View History

2022-02-02 15:29:29 +00:00
package love.distributedrebirth.bassboonyd;
import java.util.Arrays;
import java.util.List;
2022-02-11 12:48:24 +00:00
import java.util.Map;
import java.util.function.Consumer;
2022-02-11 12:48:24 +00:00
import java.util.function.Function;
import java.util.stream.Collectors;
2022-10-15 00:34:58 +00:00
import love.distributedrebirth.bassboonyd.info.BãßBȍőnAuthor注;
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
2022-10-13 23:35:53 +00:00
public interface DefaultEnumSetʸᴰ<T, K extends BãßBȍőnCoffinStoreKeyʸᴰ> extends DefaultEnumBaseʸᴰ<T,K> {
public static class Ꝑŕḯṿª implements BãßBȍőnꝐŕḯṿª {
private static final String GHOST_KEY_RANG_TEL_EEN = "rangTelEen";
2022-10-15 00:34:58 +00:00
@BãßBȍőnꝐŕḯṿªḕInit注()
private static void init(DefaultEnumSetʸᴰ<?,?> boon) {
boon.GET_BBC().UNHOLY(Ꝑŕḯṿª.class).PUT_GHOST(GHOST_KEY_RANG_TEL_EEN, boon.BȍőnRangTelNul() + BãßBȍőnConstantsʸᴰ.INT_ONE);
2022-10-13 23:35:53 +00:00
}
}
2022-02-02 16:34:46 +00:00
2022-02-02 17:01:10 +00:00
default int BȍőnRangTelNul() {
2022-02-02 16:34:46 +00:00
return ordinal();
}
2022-02-02 17:01:10 +00:00
default int BȍőnRangTelEen() {
2022-10-13 23:35:53 +00:00
return GET_BBC().UNHOLY(Ꝑŕḯṿª.class).GHOST_INT(Ꝑŕḯṿª.GHOST_KEY_RANG_TEL_EEN);
2022-02-02 16:34:46 +00:00
}
2022-02-02 17:01:10 +00:00
default List<T> BãßInstancesList() {
return Arrays.asList(BãßInstances());
}
2022-10-13 23:35:53 +00:00
default Map<String,T> BãßInstancesToMap(Function<T,String> keyMapper) {
2022-02-11 12:48:24 +00:00
return BãßInstancesList().stream().collect(Collectors.toMap(keyMapper, v -> v));
}
2022-02-02 17:01:10 +00:00
default T BȍőnVolgende() {
T[] values = BãßInstances();
2022-10-13 23:35:53 +00:00
int resultIndex = BãßBȍőnConstantsʸᴰ.INT_ZERO;
for (int i=BãßBȍőnConstantsʸᴰ.INT_ZERO;i<values.length;i++) {
if (this == values[i]) {
2022-10-13 23:35:53 +00:00
resultIndex = i + BãßBȍőnConstantsʸᴰ.INT_ONE;
break;
}
}
if (resultIndex == values.length) {
2022-10-13 23:35:53 +00:00
resultIndex = BãßBȍőnConstantsʸᴰ.INT_ZERO;
}
return values[resultIndex];
}
2022-02-02 17:01:10 +00:00
default T BȍőnVorige() {
T[] values = BãßInstances();
2022-10-13 23:35:53 +00:00
int resultIndex = BãßBȍőnConstantsʸᴰ.INT_ZERO;
for (int i=BãßBȍőnConstantsʸᴰ.INT_ZERO;i<values.length;i++) {
if (this == values[i]) {
2022-10-13 23:35:53 +00:00
resultIndex = i - BãßBȍőnConstantsʸᴰ.INT_ONE;
break;
}
}
2022-10-13 23:35:53 +00:00
if (resultIndex < BãßBȍőnConstantsʸᴰ.INT_ZERO) {
resultIndex = values.length - BãßBȍőnConstantsʸᴰ.INT_ONE;
}
return values[resultIndex];
}
2022-02-02 17:55:21 +00:00
default void BãßVoorElk(Consumer<T> consumer) {
2022-02-02 17:01:10 +00:00
for (T value:BãßInstances()) {
consumer.accept(value);
}
}
}