pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
+15 -27
View File
@@ -3,28 +3,22 @@ package appeng.util;
import java.util.EnumSet;
/**
* Simple utility class to help with select the "next" or "previous" value in a list of options represented
* by an enumeration.
* Simple utility class to help with select the "next" or "previous" value in a
* list of options represented by an enumeration.
*/
public final class EnumCycler {
private EnumCycler() {
}
public static <T extends Enum<T>> T rotateEnum( T ce, final boolean backwards, final EnumSet<T> validOptions )
{
do
{
if( backwards )
{
ce = prevEnum( ce );
public static <T extends Enum<T>> T rotateEnum(T ce, final boolean backwards, final EnumSet<T> validOptions) {
do {
if (backwards) {
ce = prevEnum(ce);
} else {
ce = next(ce);
}
else
{
ce = next( ce );
}
}
while( !validOptions.contains( ce ) );
} while (!validOptions.contains(ce));
return ce;
}
@@ -32,18 +26,15 @@ public final class EnumCycler {
/*
* Simple way to cycle an enum...
*/
public static <T extends Enum<T>> T prevEnum( final T ce )
{
public static <T extends Enum<T>> T prevEnum(final T ce) {
T[] values = ce.getDeclaringClass().getEnumConstants();
int pLoc = ce.ordinal() - 1;
if( pLoc < 0 )
{
if (pLoc < 0) {
pLoc = values.length - 1;
}
if( pLoc < 0 || pLoc >= values.length )
{
if (pLoc < 0 || pLoc >= values.length) {
pLoc = 0;
}
@@ -53,18 +44,15 @@ public final class EnumCycler {
/*
* Simple way to cycle an enum...
*/
public static <T extends Enum<T>> T next(final T ce )
{
public static <T extends Enum<T>> T next(final T ce) {
T[] values = ce.getDeclaringClass().getEnumConstants();
int pLoc = ce.ordinal() + 1;
if( pLoc >= values.length )
{
if (pLoc >= values.length) {
pLoc = 0;
}
if( pLoc < 0 || pLoc >= values.length )
{
if (pLoc < 0 || pLoc >= values.length) {
pLoc = 0;
}