lumbermill.api.Sys Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lumbermill-core Show documentation
Show all versions of lumbermill-core Show documentation
Where Logs are cut into Lumber
The newest version!
package lumbermill.api;
import static java.lang.String.format;
import static java.lang.String.valueOf;
public class Sys {
public static Env env (String name, String defaulT) {
return System.getenv (name) != null ? new Env(System.getenv (name)) : new Env(defaulT);
}
public static Env env (String name) {
String value = System.getenv (name) != null ? System.getenv (name) : null;
if (value != null) {
return new Env(value);
}
throw new IllegalStateException (format("No System env found for name %s", name));
}
public static class Env {
private final String value;
Env (String value) {
this.value = value;
}
public String string() {
return value;
}
public boolean bool() {
return Boolean.valueOf (value);
}
public int number() {
return Integer.parseInt (value);
}
}
}