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
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 Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
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
Modifier and TypeMethodDescriptionboolean
exists()
protected static @Nullable String
getEnvironmentVariable
(@NotNull String variable, boolean mandatory) Obtain the specified environment variable.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
Obtain the value of the property (returns the default value if the environment variable has not been defined.void
So the setting can be set by a testtoString()
-
Field Details
-
myPropertyValue
-
myPropertyKey
-
-
Constructor Details
-
AbstractSystemProperty
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
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 Details
-
getValue
public int getValue(int defaultValue) -
getValue
public long getValue(long defaultValue) -
toString
-
getValue
Obtain the value of this property- Returns:
- The value (null if the environment variable has not been defined)
-
getKey
Obtain the key used to find this property- Returns:
- The key (null if environment variable has not been defined)
-
getValue
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
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
-