Package com.atlassian.bamboo.utils
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 fromSystemProperty
while at the same time being used as type of its static fields.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
myPropertyKey
protected String
myPropertyValue
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSystemProperty(boolean mandatory, String... properties)
Creates an instance containing the value of the given property - logs an error if it cannot be foundprotected
AbstractSystemProperty(String property, boolean mandatory, org.apache.log4j.Logger log)
Used in testing
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
exists()
protected static @Nullable String
getEnvironmentVariable(@NotNull String variable, boolean mandatory)
Obtain the specified environment variable.String
getKey()
Obtain the key used to find this property@Nullable String
getValue()
Obtain the value of this propertyboolean
getValue(boolean defaultValue)
Obtain the boolean property valueint
getValue(int defaultValue)
long
getValue(long defaultValue)
@NotNull String
getValue(@NotNull String defaultValue)
Obtain the value of the property (returns the default value if the environment variable has not been defined.void
setValue(String propertyValue)
So the setting can be set by a testString
toString()
-
-
-
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 environmentmandatory
- 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 requiremandatory
- Is this a mandatory property?- Returns:
- The value of the variable, null if not found
-
-