added jmath library
This commit is contained in:
@@ -22,6 +22,11 @@ public class Hash {
|
||||
SHA512("SHA-512");
|
||||
|
||||
private final String key;
|
||||
|
||||
@SneakyThrows
|
||||
public MessageDigest newMessageDigest() {
|
||||
return MessageDigest.getInstance(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
25
src/main/java/net/woggioni/jwo/Requirement.java
Normal file
25
src/main/java/net/woggioni/jwo/Requirement.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package net.woggioni.jwo;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static net.woggioni.jwo.JWO.newThrowable;
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class Requirement {
|
||||
private final Supplier<Boolean> booleanSupplier;
|
||||
|
||||
public static Requirement require(Supplier<Boolean> booleanSupplier) {
|
||||
return new Requirement(booleanSupplier);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public <T extends Throwable> void otherwise(Class<T> cls, String format, Object... args) {
|
||||
if(!booleanSupplier.get()) {
|
||||
throw newThrowable(cls, format, args);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user