forked from Thorfusion/Mekanism-Community-Edition
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
1,574 additions
and
1,022 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package mekanism.api; | ||
|
||
import java.util.function.Predicate; | ||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Interface for enum's to make them easily incremental, while allowing for disabling various elements | ||
*/ | ||
public interface IDisableableEnum<TYPE extends Enum<TYPE> & IDisableableEnum<TYPE>> extends IIncrementalEnum<TYPE> { | ||
|
||
/** | ||
* Used to check if a given element is enabled. | ||
* | ||
* @return {@code true} if the element is enabled, {@code false} otherwise. | ||
*/ | ||
boolean isEnabled(); | ||
|
||
@Nonnull | ||
@Override | ||
default TYPE getNext(@Nonnull Predicate<TYPE> isValid) { | ||
return IIncrementalEnum.super.getNext(element -> element.isEnabled() && isValid.test(element)); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
default TYPE getPrevious(@Nonnull Predicate<TYPE> isValid) { | ||
return IIncrementalEnum.super.getPrevious(element -> element.isEnabled() && isValid.test(element)); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
default TYPE adjust(int shift) { | ||
//Note: We can just pass an always true predicate as we intercept getNext and getPrevious calls to | ||
// ensure that they test the element is enabled | ||
return adjust(shift, value -> true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.