Class EnvironmentPropertyValue

  • All Implemented Interfaces:
    java.security.PrivilegedAction<java.lang.String>, Value<java.lang.String>

    public final class EnvironmentPropertyValue
    extends java.lang.Object
    implements Value<java.lang.String>, java.security.PrivilegedAction<java.lang.String>
    A value which comes from an environment property.
    See Also:
    System.getenv(String)
    • Constructor Summary

      Constructors 
      Constructor Description
      EnvironmentPropertyValue​(java.lang.String propertyName)
      Construct a new instance.
      EnvironmentPropertyValue​(java.lang.String propertyName, java.security.AccessControlContext accessControlContext)
      Construct a new instance.
      EnvironmentPropertyValue​(java.lang.String propertyName, java.security.AccessControlContext accessControlContext, Value<?> defaultValue)
      Construct a new instance.
      EnvironmentPropertyValue​(java.lang.String propertyName, Value<?> defaultValue)
      Construct a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getValue()
      Get the actual value.
      java.lang.String run()
      Fetch the property in an unprivileged context.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • propertyName

        private final java.lang.String propertyName
      • accessControlContext

        private final java.security.AccessControlContext accessControlContext
      • defaultValue

        private final Value<?> defaultValue
    • Constructor Detail

      • EnvironmentPropertyValue

        public EnvironmentPropertyValue​(java.lang.String propertyName)
        Construct a new instance.
        Parameters:
        propertyName - the property name to read
      • EnvironmentPropertyValue

        public EnvironmentPropertyValue​(java.lang.String propertyName,
                                        java.security.AccessControlContext accessControlContext)
        Construct a new instance.
        Parameters:
        propertyName - the property name to read
        accessControlContext - the access control context in which to fetch the property value
      • EnvironmentPropertyValue

        public EnvironmentPropertyValue​(java.lang.String propertyName,
                                        Value<?> defaultValue)
        Construct a new instance.
        Parameters:
        propertyName - the property name to read
        defaultValue - the value to use if the property is unset
      • EnvironmentPropertyValue

        public EnvironmentPropertyValue​(java.lang.String propertyName,
                                        java.security.AccessControlContext accessControlContext,
                                        Value<?> defaultValue)
        Construct a new instance.
        Parameters:
        propertyName - the property name to read
        accessControlContext - the access control context in which to fetch the property value
        defaultValue - the value to use if the property is unset
    • Method Detail

      • getValue

        public java.lang.String getValue()
                                  throws java.lang.IllegalStateException,
                                         java.lang.IllegalArgumentException
        Get the actual value.
        Specified by:
        getValue in interface Value<java.lang.String>
        Returns:
        the actual value
        Throws:
        java.lang.IllegalStateException - if the value is time-sensitive and the current state does not allow retrieval.
        java.lang.IllegalArgumentException - when the value cannot be read due to misconfiguration
      • run

        public java.lang.String run()
        Fetch the property in an unprivileged context.
        Specified by:
        run in interface java.security.PrivilegedAction<java.lang.String>
        Returns:
        the property value