This repository has been archived by the owner on Apr 9, 2023. It is now read-only.
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
1 parent
fc47b48
commit 98b5ffa
Showing
29 changed files
with
219 additions
and
58 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
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
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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
package ch.awae.utils.functional; | ||
|
||
/** | ||
* Similar to {@link java.util.function.Supplier} but able to throw any | ||
* arbitrary exception. | ||
* | ||
* @author Andreas Wälchli | ||
* @since awaeUtils 1.0.0 | ||
*/ | ||
@FunctionalInterface | ||
public interface FailableFunction0<T> { | ||
|
||
T apply() throws Throwable; | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/ch/awae/utils/functional/FailableFunction1.java
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
7 changes: 0 additions & 7 deletions
7
src/main/java/ch/awae/utils/functional/InterruptableRunnable.java
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
src/main/java/ch/awae/utils/functional/InterruptibleRunnable.java
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,15 @@ | ||
package ch.awae.utils.functional; | ||
|
||
/** | ||
* Similar to {@link java.lang.Runnable} but with the ability to be interrupted. | ||
* This can be used instead of {@link FailableRunnable} if only | ||
* {@link InterruptedException} should be allowed. | ||
* | ||
* @author Andreas Wälchli | ||
* @since awaeUtils 0.0.6 | ||
*/ | ||
public interface InterruptibleRunnable { | ||
|
||
void run() throws InterruptedException; | ||
|
||
} |
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
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
24 changes: 22 additions & 2 deletions
24
src/main/java/ch/awae/utils/sequence/IRootSequenceBuilder.java
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
28 changes: 26 additions & 2 deletions
28
src/main/java/ch/awae/utils/sequence/ISequenceBuilder.java
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 |
---|---|---|
@@ -1,15 +1,39 @@ | ||
package ch.awae.utils.sequence; | ||
|
||
import ch.awae.utils.functional.InterruptableRunnable; | ||
import ch.awae.utils.functional.InterruptibleRunnable; | ||
|
||
/** | ||
* Base interface for all sequence builders | ||
* | ||
* @author Andreas Wälchli | ||
* @since awaeUtils 0.0.6 | ||
*/ | ||
public interface ISequenceBuilder<T extends ISequenceBuilder<T>> { | ||
|
||
T step(InterruptableRunnable step); | ||
/** | ||
* adds a step to the sequence | ||
* | ||
* @return the builder itself. for chaining | ||
*/ | ||
T step(InterruptibleRunnable step); | ||
|
||
/** | ||
* adds a step that sleeps for a given number of milliseconds. The step | ||
* makes a call to {@link Thread#sleep(long)} internally | ||
* | ||
* @return the builder itself for chaining | ||
*/ | ||
default T sleep(long millis) { | ||
return step(() -> Thread.sleep(millis)); | ||
} | ||
|
||
/** | ||
* start a finite loop with a given number of iterations | ||
* | ||
* @param iterations | ||
* the number of times the loop should be repeated | ||
* @return the bbuilder itself for chaining | ||
*/ | ||
ISubSequenceBuilder<T> loop(int iterations); | ||
|
||
} |
14 changes: 13 additions & 1 deletion
14
src/main/java/ch/awae/utils/sequence/ISubSequenceBuilder.java
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 |
---|---|---|
@@ -1,7 +1,19 @@ | ||
package ch.awae.utils.sequence; | ||
|
||
/** | ||
* sequence builder for sub-sequences. Subsequences are created by starting | ||
* loops | ||
* | ||
* @author Andreas Wälchli | ||
* @since awaeUtils 0.0.6 | ||
*/ | ||
public interface ISubSequenceBuilder<T extends ISequenceBuilder<T>> extends ISequenceBuilder<ISubSequenceBuilder<T>> { | ||
|
||
/** | ||
* end the loop represented by this sub-sequence | ||
* | ||
* @return the parent sequence builder | ||
*/ | ||
T end(); | ||
|
||
} |
14 changes: 7 additions & 7 deletions
14
src/main/java/ch/awae/utils/sequence/RootSequenceBuilder.java
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.