Class AbstractSystemProperty

    • Field Detail

      • myPropertyValue

        protected String myPropertyValue
      • myPropertyKey

        protected String myPropertyKey
    • Constructor Detail

      • AbstractSystemProperty

        protected AbstractSystemProperty​(boolean mandatory,
                                         String... properties)
        Creates an instance containing the value of the given property - logs an error if it cannot be found
        Parameters:
        mandatory - Is the property mandatory or optional?
        properties - The property we're loading from the environment (first name found will be loaded)
      • AbstractSystemProperty

        protected AbstractSystemProperty​(String property,
                                         boolean mandatory,
                                         org.apache.log4j.Logger log)
        Used in testing
        Parameters:
        property - The property we're loading from the environment
        mandatory - Is the property mandatory or optional?
        log - The logger we're logging errors to
    • Method Detail

      • getValue

        public int getValue​(int defaultValue)
      • getValue

        public long getValue​(long defaultValue)
      • getValue

        @Nullable
        public @Nullable String getValue()
        Obtain the value of this property
        Returns:
        The value (null if the environment variable has not been defined)
      • getKey

        public String getKey()
        Obtain the key used to find this property
        Returns:
        The key (null if environment variable has not been defined)
      • getValue

        @NotNull
        public @NotNull String getValue​(@NotNull
                                        @NotNull String defaultValue)
        Obtain the value of the property (returns the default value if the environment variable has not been defined.
        Parameters:
        defaultValue - The default value, if the environment variable has not been defined
        Returns:
        The value of the property
      • getValue

        public boolean getValue​(boolean defaultValue)
        Obtain the boolean property value
        Parameters:
        defaultValue - The default value, if the environment variable has not been defined
        Returns:
        The value of the property
      • setValue

        public void setValue​(String propertyValue)
        So the setting can be set by a test
        Parameters:
        propertyValue - The value required by the test
      • exists

        public boolean exists()
      • getEnvironmentVariable

        @Nullable
        protected static @Nullable String getEnvironmentVariable​(@NotNull
                                                                 @NotNull String variable,
                                                                 boolean mandatory)
        Obtain the specified environment variable. An error is logged if a mandatory value does not exist.
        Parameters:
        variable - The variable we require
        mandatory - Is this a mandatory property?
        Returns:
        The value of the variable, null if not found