mirror of
https://github.com/Noratrieb/UselessClasses.git
synced 2026-01-15 00:55:07 +01:00
IF(true, () -> github.deleteRepo(this));
This commit is contained in:
parent
d9f980f1a9
commit
7167e0ca80
2 changed files with 62 additions and 0 deletions
28
src/main/java/com/github/nilstrieb/uselessclasses/Ifs.java
Normal file
28
src/main/java/com/github/nilstrieb/uselessclasses/Ifs.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package com.github.nilstrieb.uselessclasses;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* This class adds a brand new syntax for if-statements!
|
||||
* You just need to statically import the methods
|
||||
*/
|
||||
public class Ifs {
|
||||
public static void IF(boolean condition, Statements onTrue) {
|
||||
IF(condition, onTrue, () -> {});
|
||||
}
|
||||
|
||||
public static void IF(boolean condition, Statements onTrue, Statements onFalse) {
|
||||
if(condition){
|
||||
onTrue.execute();
|
||||
} else {
|
||||
onFalse.execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
interface Statements {
|
||||
void execute();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue