Interface SystemWrapper

  • All Known Implementing Classes:
    DefaultSystemWrapper, TestSystemWrapper

    public interface SystemWrapper
    This wrapper interface permits to bootstrap different System mechanism according to the context of execution. This interface ensures nothing of wrong is done with the System properties and as such it can use a security manager.
    Author:
    Yohann Chastagnier
    • Method Detail

      • get

        static SystemWrapper get()
        Gets the wrapped System instance.
        Returns:
        the instance of the System Wrapper.
      • getenv

        String getenv​(String name)
        Gets the value of a environment variable.
        Parameters:
        name - the name of the variable.
        Returns:
        the value of the requested environment variable.
      • getenv

        Map<String,​String> getenv()
        Gets all the environment variables.
        Returns:
        the map of environment variables.
      • setProperty

        String setProperty​(String key,
                           String value)
        Sets a new system property. If the property isn't valued, id est has a null or an empty value, then it is not set. Only non-null and not empty property can be set.
        Parameters:
        key - the key of the property.
        value - a non-null and non-empty value of the property.
        Returns:
        the previous value of the system property, or null if it did not have one or if the property to set isn't valid.
        See Also:
        System.setProperty(String, String)
      • getProperty

        String getProperty​(String key)
        Gets a system property.
        Parameters:
        key - the key of the system property.
        Returns:
        the string value of the system property, or null if there is no property with that key.
      • getProperty

        String getProperty​(String key,
                           String def)
        Gets a system property.
        Parameters:
        key - the key of the system property.
        def - the default value if there is no property value with the key.
        Returns:
        the string value of the system property, or the default value if there is no property with that key.