gdxapp4d/demo4d-bassboonyd/src/main/love/distributedrebirth/bassboonyd/BãßBȍőnEnumSetʸᴰ.java

70 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.Iterator;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;
2022-02-02 17:01:10 +00:00
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
2022-02-02 16:34:46 +00:00
public interface BãßBȍőnEnumSetʸᴰ<T> extends BãßBȍőnEnumʸᴰ<T> {
2022-02-02 16:34:46 +00:00
int ordinal();
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-02 17:01:10 +00:00
default Iterator<T> BãßInstancesIterator() {
return BãßInstancesList().iterator();
}
2022-02-02 17:01:10 +00:00
default Stream<T> BãßInstancesStream() {
return BãßInstancesList().stream();
}
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);
}
}
}