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

65 lines
1.4 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-08-24 15:33:39 +00:00
@BãßBȍőnAuthorInfoʸᴰ(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
2022-02-06 16:19:05 +00:00
public interface DefaultEnumSetʸᴰ<T> extends DefaultEnumBaseʸᴰ<T> {
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-02-02 16:34:46 +00:00
return ordinal() + 1;
}
2022-02-02 17:01:10 +00:00
default List<T> BãßInstancesList() {
return Arrays.asList(BãßInstances());
}
2022-02-11 12:48:24 +00:00
default <K> Map<K,T> BãßInstancesToMap(Function<T,K> keyMapper) {
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();
int resultIndex = 0;
for (int i=0;i<values.length;i++) {
if (this == values[i]) {
resultIndex = i + 1;
break;
}
}
if (resultIndex == values.length) {
resultIndex = 0;
}
return values[resultIndex];
}
2022-02-02 17:01:10 +00:00
default T BȍőnVorige() {
T[] values = BãßInstances();
int resultIndex = 0;
for (int i=0;i<values.length;i++) {
if (this == values[i]) {
resultIndex = i - 1;
break;
}
}
if (resultIndex < 0) {
resultIndex = values.length - 1;
}
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);
}
}
}