All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.crazyyak.dev.common.EnvUtils Maven / Gradle / Ivy

package org.crazyyak.dev.common;

public class EnvUtils {

  private EnvUtils() {
  }

  public static String findProperty(String propertyName) {
    return findProperty(propertyName, null);
  }

  public static String findProperty(String propertyName, String defaultValue) {
    String actualValue = getSystemProperty(propertyName);
    if (StringUtils.isBlank(actualValue)) {
      actualValue = getEnvironmentProperty(propertyName);
    }
    return (StringUtils.isBlank(actualValue)) ? defaultValue : actualValue;
  }

  public static String getEnvironmentProperty(String propertyName) {
    return System.getenv(propertyName);
  }

  public static String getEnvironmentProperty(String propertyName, String defaultValue) {
    String actualValue = System.getenv(propertyName);
    return (StringUtils.isBlank(actualValue)) ? defaultValue : actualValue;
  }

  public static String getSystemProperty(String propertyName) {
    return System.getProperty(propertyName);
  }

  public static String getSystemProperty(String propertyName, String defaultValue) {
    String actualValue = System.getProperty(propertyName);
    return (StringUtils.isBlank(actualValue)) ? defaultValue : actualValue;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy