public class TeamCityProperties
extends java.lang.Object
The access is provided via get* methods, all of which first look up the key in a file,
then * loop it up in System.getProperties().
The properties file is optional, but if it exists, it is reread on each modification
(sleep interval is 10 seconds by default, and can be set manually using
"teamcity.internal.properties.reread.interval.ms" property) .
All access methods are thread-safe and never throw exceptions. Performance note: all access methods are never blocked to read the value from the file. In case the file is removed, last used properties map is in effect.
Also note that the errors are not reported to the log, because the log environment might be not initialized yet (it can require a system property for that =).
| Modifier and Type | Class and Description |
|---|---|
static interface |
TeamCityProperties.Model
Represents properties access model.
|
| Constructor and Description |
|---|
TeamCityProperties() |
| Modifier and Type | Method and Description |
|---|---|
static com.intellij.openapi.util.Pair<java.util.Properties,java.util.Properties> |
getAllProperties()
Deprecated.
use
getModel().getUserDefinedProperties and getModel().getSystemProperties() |
static boolean |
getBoolean(java.lang.String key)
Returns the property value as a boolean, or
false if not set. |
static boolean |
getBooleanOrTrue(java.lang.String key)
Returns the property value as a boolean, or
true if not set. |
static float |
getFloat(java.lang.String key)
Returns the property value as a float, or
0.0f if not set. |
static float |
getFloat(java.lang.String key,
float defaultValue)
Returns the property value as a float.
|
static int |
getInteger(java.lang.String key)
Returns the property value as an integer, or
0 if not set. |
static int |
getInteger(java.lang.String key,
int defaultValue)
Returns the property value as an integer.
|
static long |
getIntervalMilliseconds(java.lang.String key,
long defaultMillis)
Returns the property value representing a time interval in milliseconds.
|
static long |
getLong(java.lang.String key)
Returns the property value as a long, or
0 if not set. |
static long |
getLong(java.lang.String key,
long defaultValue)
Returns the property value as a long.
|
static TeamCityProperties.Model |
getModel() |
static java.util.Map<java.lang.String,java.lang.String> |
getPropertiesWithPrefix(java.lang.String keyPrefix) |
static java.lang.String |
getProperty(java.lang.String key)
Returns the property value as a string, or empty string if not set.
|
static java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue)
Returns the property value as a string.
|
static java.lang.String |
getPropertyOrNull(java.lang.String key)
Returns the property value as a string, or
null if not set. |
static java.lang.String |
getPropertyOrNull(java.lang.String key,
java.lang.String defaultValue)
Returns the property value as a string, or
null if not set. |
static boolean |
isInitialized() |
protected static void |
setModel(TeamCityProperties.Model model)
Updates current TeamCity properties model.
|
public static boolean getBoolean(@NotNull
java.lang.String key)
false if not set.key - the property keypublic static boolean getBooleanOrTrue(@NotNull
java.lang.String key)
true if not set.key - the property keypublic static int getInteger(@NotNull
java.lang.String key)
0 if not set.key - the property keypublic static long getIntervalMilliseconds(@NotNull
java.lang.String key,
long defaultMillis)
The value can be defined in the properties file several ways: - {key} or {key}.millis to define interval in milliseconds - {key}.seconds to define interval in seconds - {key}.minutes to define interval in minutes - {key}.hours to define interval in hours
public static int getInteger(@NotNull
java.lang.String key,
int defaultValue)
key - the property keydefaultValue - default valuepublic static float getFloat(@NotNull
java.lang.String key)
0.0f if not set.key - the property keypublic static float getFloat(@NotNull
java.lang.String key,
float defaultValue)
key - the property keydefaultValue - default valuepublic static long getLong(@NotNull
java.lang.String key)
0 if not set.key - the property keypublic static long getLong(@NotNull
java.lang.String key,
long defaultValue)
key - the property keydefaultValue - default value@NotNull
public static java.lang.String getProperty(@NotNull
java.lang.String key)
key - the property key@Nullable
public static java.lang.String getPropertyOrNull(@NotNull
java.lang.String key)
null if not set.key - the property key@Nullable
public static java.lang.String getPropertyOrNull(@NotNull
java.lang.String key,
@Nullable
java.lang.String defaultValue)
null if not set.key - the property keydefaultValue - default value@NotNull
public static java.lang.String getProperty(@NotNull
java.lang.String key,
@NotNull
java.lang.String defaultValue)
key - the property keydefaultValue - default value@NotNull
public static java.util.Map<java.lang.String,java.lang.String> getPropertiesWithPrefix(@NotNull
java.lang.String keyPrefix)
keyPrefix - key prefix@NotNull @Deprecated public static com.intellij.openapi.util.Pair<java.util.Properties,java.util.Properties> getAllProperties()
getModel().getUserDefinedProperties and getModel().getSystemProperties()Properties instances containing system properties: the first one contains properties
from the internal file, the second one contains all Java process properties (System.getProperties()).
Note that entries from the first map overwrite the ones from the second map.
@NotNull public static TeamCityProperties.Model getModel()
public static boolean isInitialized()
protected static void setModel(@NotNull
TeamCityProperties.Model model)
model - new model