Class AbstractSystemProperty

java.lang.Object
com.atlassian.bamboo.utils.AbstractSystemProperty
Direct Known Subclasses:
SystemProperty, SystemProperty.BooleanSystemProperty, SystemProperty.IntegerSystemProperty, SystemProperty.UrlSystemProperty

@Internal public abstract class AbstractSystemProperty extends Object
Common ancestor for all SystemProperty classes. It is needed to avoid classloader deadlock that would happen if specialised classes inherited from SystemProperty while at the same time being used as type of its static fields.
  • Field Details

    • myPropertyValue

      protected String myPropertyValue
    • myPropertyKey

      protected String myPropertyKey
  • Constructor Details

    • 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 Details

    • getValue

      public int getValue(int defaultValue)
    • getValue

      public long getValue(long defaultValue)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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