示例#1
0
  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;
  }
示例#2
0
文件: Sys.java 项目: gatling/boon
  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;
  }
示例#3
0
文件: Sys.java 项目: gatling/boon
  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);
  }
示例#4
0
文件: Sys.java 项目: gatling/boon
  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);
  }
示例#5
0
文件: Sys.java 项目: gatling/boon
  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);
  }
示例#6
0
文件: Sys.java 项目: gatling/boon
  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);
  }
示例#7
0
文件: Sys.java 项目: gatling/boon
  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);
  }