added Automatic-Module-Name to jar manifest and some utility methods

This commit is contained in:
2020-11-13 09:15:39 +01:00
parent 9d25d70cfe
commit f96ab24ad7
3 changed files with 21 additions and 1 deletions

View File

@@ -3,11 +3,23 @@ package net.woggioni.worth.utils;
import lombok.SneakyThrows;
import net.woggioni.worth.xface.Value;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
public class WorthUtils {
public static Optional<Value> nested(Value root, String... keys) {
Value result = root;
for (String key : keys) {
result = result.get(key);
if (result == null) {
break;
}
}
return Optional.ofNullable(result);
}
public static Value getOrNull(Value root, String... keys) {
Value result = root;
for (String key : keys) {

View File

@@ -18,6 +18,10 @@ public interface Value {
Type type();
default boolean isNull() {
return type() == Value.Null.type();
}
default boolean asBoolean() {
throw new TypeException("Not a boolean");
}