Start with bassboonyd package
This commit is contained in:
parent
e998603843
commit
645a10ef4c
21 changed files with 66 additions and 38 deletions
7
demo4d-bassboonyd/build.gradle
Normal file
7
demo4d-bassboonyd/build.gradle
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
sourceCompatibility = appJvmCode
|
||||
[compileJava, compileTestJava]*.options*.encoding = appEncoding
|
||||
|
||||
sourceSets.main.java.srcDirs = [ "src/main/"]
|
||||
sourceSets.main.resources.srcDirs = [ "src/resources/" ]
|
||||
sourceSets.test.java.srcDirs = [ "src/test/"]
|
||||
sourceSets.test.resources.srcDirs = [ "src/test-resources/" ]
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* Inject EnumSet methods.
|
||||
*
|
||||
* @author willemtsade ©Δ∞ 仙上主天
|
||||
*/
|
||||
public interface BaßBȍőnEnumSetʸᴰ<T> extends BaßBȍőnEnumʸᴰ<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default T[] staticInstances() {
|
||||
try {
|
||||
Object result = getClass().getMethod("values").invoke(null);
|
||||
return (T[]) result;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
default List<T> staticInstancesList() {
|
||||
return Arrays.asList(staticInstances());
|
||||
}
|
||||
|
||||
default Iterator<T> staticInstancesIterator() {
|
||||
return staticInstancesList().iterator();
|
||||
}
|
||||
|
||||
default Stream<T> staticInstancesStream() {
|
||||
return staticInstancesList().stream();
|
||||
}
|
||||
|
||||
default T volgende() {
|
||||
T[] values = staticInstances();
|
||||
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];
|
||||
}
|
||||
|
||||
default T vorige() {
|
||||
T[] values = staticInstances();
|
||||
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];
|
||||
}
|
||||
|
||||
default void staticVoorElk(Consumer<T> consumer) {
|
||||
for (T value:staticInstances()) {
|
||||
consumer.accept(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package love.distributedrebirth.bassboonyd;
|
||||
|
||||
/**
|
||||
* Inject Enum methods.
|
||||
*
|
||||
* @author willemtsade ©Δ∞ 仙上主天
|
||||
*/
|
||||
public interface BaßBȍőnEnumʸᴰ<T> {
|
||||
|
||||
int ordinal();
|
||||
|
||||
String name();
|
||||
|
||||
default String naam() {
|
||||
return name(); // Deutsche code
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package love.distributedrebirth.bassboonyd;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Defines the BaßBȍőn name.
|
||||
*
|
||||
* @author willemtsade ©Δ∞ 仙上主天
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
public @interface BaßBȍőnNaamʸᴰ {
|
||||
|
||||
String value();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue