added jmath library

This commit is contained in:
2023-05-14 15:38:15 +08:00
parent 99a557f192
commit 9b09c6bd73
25 changed files with 1592 additions and 25 deletions

View File

@@ -22,6 +22,11 @@ public class Hash {
SHA512("SHA-512");
private final String key;
@SneakyThrows
public MessageDigest newMessageDigest() {
return MessageDigest.getInstance(key);
}
}
@Getter

View 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);
}
}
}