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

@@ -27,6 +27,10 @@ javacOptions in (Compile, compile) ++= Seq("-target", "8", "-source", "8")
libraryDependencies += "org.projectlombok" % "lombok" % "1.18.8" % Provided
libraryDependencies += "net.woggioni" % "jwo" % "1.0" % Compile
Compile / packageBin / packageOptions +=
Package.ManifestAttributes("Automatic-Module-Name" -> "net.woggioni.worth")
val testDependencies = Seq("com.novocode" % "junit-interface" % "0.11" % Test,
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.6" % Test,
"org.tukaani" % "xz" % "1.8" % Test)

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