public static <T extends Enum> T toEnum(Class<T> cls, String value, Enum defaultEnum) { T[] enumConstants = cls.getEnumConstants(); for (T e : enumConstants) { if (e.name().equals(value)) { return e; } } value = value.toUpperCase().replace('-', '_'); for (T e : enumConstants) { if (e.name().equals(value)) { return e; } } value = Str.underBarCase(value); for (T e : enumConstants) { if (e.name().equals(value)) { return e; } } return (T) defaultEnum; }
private static String _sysProp(String key, Object defaultValue) { String property = (String) systemProperties.get(key); if (property == null) { property = env.get(key); if (property == null) { String newKey = Str.underBarCase(key); property = env.get(newKey); if (property == null && defaultValue != DEFAULT_NULL_NOT_EMPTY) { property = Conversions.toString(defaultValue); } } } return property; }
public static <T extends Enum> T sysProp(Class<T> cls, String key, T defaultValue) { String property = (String) systemProperties.get(key); if (property == null) { property = env.get(key); } if (property == null) { String newKey = Str.underBarCase(key); property = env.get(newKey); } if (property == null) { return defaultValue; } return Conversions.toEnum(cls, property); }
public static BigInteger sysPropBigInteger(String key, BigInteger defaultValue) { String property = (String) systemProperties.get(key); if (property == null) { property = env.get(key); } if (property == null) { String newKey = Str.underBarCase(key); property = env.get(newKey); } if (property == null) { return defaultValue; } return Conversions.toBigInteger(property); }
public static byte sysProp(String key, byte defaultValue) { String property = (String) systemProperties.get(key); if (property == null) { property = env.get(key); } if (property == null) { String newKey = Str.underBarCase(key); property = env.get(newKey); } if (property == null) { return defaultValue; } return Conversions.toByte(property); }
public static Path sysProp(String key, Path defaultValue) { String property = (String) systemProperties.get(key); if (property == null) { property = env.get(key); } if (property == null) { String newKey = Str.underBarCase(key); property = env.get(newKey); } if (property == null) { return defaultValue; } return IO.path(property); }
public static File sysProp(String key, File defaultValue) { String property = (String) systemProperties.get(key); if (property == null) { property = env.get(key); } if (property == null) { String newKey = Str.underBarCase(key); property = env.get(newKey); } if (property == null) { return defaultValue; } return new File(property); }