Module iu.util
Package edu.iu

Class IuRuntimeEnvironment

java.lang.Object
edu.iu.IuRuntimeEnvironment

public class IuRuntimeEnvironment extends Object
Provides basic utilities for inspecting the runtime environment.

Runtime properties should be used sparingly, sufficient only to support bootstrapping the application's configuration management layer.

  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    env(String name)
    Checks for the presence of a system property, then defaults to an environment variable if not set.
    static <T> T
    env(String name, Function<String,T> textToValueFunction)
    Checks for the presence of a system property, then defaults to an environment variable if not set.
    static String
    Checks for the presence of a system property, then defaults to an environment variable if not set.
    static <T> T
    envOptional(String name, Function<String,T> textToValueFunction)
    Checks for the presence of a system property, then defaults to an environment variable if not set.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • envOptional

      public static <T> T envOptional(String name, Function<String,T> textToValueFunction)
      Checks for the presence of a system property, then defaults to an environment variable if not set. If the system property is set, but blank, returns null.
      Type Parameters:
      T - value type
      Parameters:
      name - property name. Must start with a letter and contain only letters, digits, '_', '-', and '.'. Will be converted to upper case, '.' and '-' replaced with '_', for checking the environment.
      textToValueFunction - converts a non-null property value to the target type; not applied to null
      Returns:
      system property value if set, environment variable if not set, null if blank or both are missing
    • envOptional

      public static String envOptional(String name)
      Checks for the presence of a system property, then defaults to an environment variable if not set. If the system property is set, but blank, returns null.
      Parameters:
      name - property name. Must start with a letter and contain only letters, digits, '_', '-', and '.'. Will be converted to upper case, '.' and '-' replaced with '_', for checking the environment.
      Returns:
      system property value if set, environment variable if not set, null if blank or both are missing
    • env

      public static <T> T env(String name, Function<String,T> textToValueFunction)
      Checks for the presence of a system property, then defaults to an environment variable if not set.
      Type Parameters:
      T - value type
      Parameters:
      name - property name
      textToValueFunction - converts a non-null property value to the target type; not applied to null
      Returns:
      system property value if set, environment variable if not set
      Throws:
      NullPointerException - if the system property is blank or both are missing
    • env

      public static String env(String name)
      Checks for the presence of a system property, then defaults to an environment variable if not set.
      Parameters:
      name - property name
      Returns:
      system property value if set, environment variable if not set
      Throws:
      NullPointerException - if the system property is blank or both are missing