io.elastic.sailor.Utils Maven / Gradle / Ivy
package io.elastic.sailor;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;
class Utils {
public static boolean isJsonObject(String input) {
try {
new Gson().fromJson(input, Object.class);
return true;
} catch (JsonSyntaxException e) {
return false;
}
}
public static boolean isJsonObject(JsonElement element) {
return element != null && element.isJsonObject();
}
public static String getEnvVar(final String key) {
final String value = getOptionalEnvVar(key);
if (value == null) {
throw new IllegalStateException(
String.format("Env var '%s' is required", key));
}
return value;
}
public static String getOptionalEnvVar(final String key) {
String value = System.getenv(key);
if (value == null) {
value = System.getProperty(key);
}
return value;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy