Package com.atlassian.bamboo.utils
Class ConfigUtils
- java.lang.Object
-
- com.atlassian.bamboo.utils.ConfigUtils
-
public class ConfigUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
BAMBOO_DELIMITER_PARSING_DISABLED
static String
FIRST_ELEMENT_IN_LIST
static String
SEPARATOR
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
addMapToBuilConfiguration(@NotNull String mapKey, @NotNull Map<String,String> map, @NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
static void
addMapToConfiguration(@NotNull String mapConfigKey, @NotNull String entryConfigKey, @NotNull Map<String,String> map, @NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
static void
addMapToConfiguration(@NotNull String mapConfigKey, @NotNull Map<String,String> map, @NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
static void
addNodeAt(org.apache.commons.configuration.HierarchicalConfiguration configuration, String rootPath, org.apache.commons.configuration.HierarchicalConfiguration configToAdd)
static void
addNodesAt(org.apache.commons.configuration.HierarchicalConfiguration config, String rootPath, org.apache.commons.configuration.HierarchicalConfiguration configToAdd)
static @NotNull Map<String,String>
asMap(@NotNull org.apache.commons.configuration.Configuration config)
static @NotNull Map<String,String>
asMap(@NotNull org.apache.commons.configuration.Configuration config, @Nullable String filter)
static Map<String,Object>
asObjectMap(@NotNull org.apache.commons.configuration.Configuration config)
static @NotNull Map<String,Object>
asObjectMap(@NotNull org.apache.commons.configuration.Configuration config, @Nullable String filter)
static String
asXmlString(@NotNull org.apache.commons.configuration.HierarchicalConfiguration hierarchicalConfiguration)
Deprecated.does not preserve bambooDelimiterParsing disabled property correctly.static @NotNull String
asXmlString(@NotNull org.apache.commons.configuration.XMLConfiguration configuration)
static void
copyMapToConfig(@NotNull Map<String,String> map, @NotNull org.apache.commons.configuration.Configuration config)
static void
copyNodes(@NotNull org.apache.commons.configuration.HierarchicalConfiguration sourceConfig, @NotNull org.apache.commons.configuration.HierarchicalConfiguration targetConfig)
static void
copyNodes(@NotNull org.apache.commons.configuration.HierarchicalConfiguration sourceConfig, @NotNull org.apache.commons.configuration.HierarchicalConfiguration targetConfig, @Nullable String key)
static void
copyObjectMapToConfig(@NotNull Map<String,Object> map, @NotNull org.apache.commons.configuration.Configuration config)
static @NotNull org.apache.commons.configuration.HierarchicalConfiguration
fromMap(@NotNull Map<String,?> map)
static <T extends org.apache.commons.configuration.Configuration>
TfromMap(@NotNull Map<String,?> map, @NotNull Supplier<T> configSupplier)
static @NotNull Map<String,String>
getMapFromConfiguration(@NotNull String mapConfigKey, @NotNull String entryConfigKey, @NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
static @NotNull Map<String,String>
getMapFromConfiguration(@NotNull String mapConfigKey, @NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
static <T> @NotNull List<T>
getPropertyAsList(@NotNull Map<String,Object> configuration, @NotNull String propertyName, @NotNull Class<T> propertyType)
Returns a given property from the configuration as a list of given type.static <T> @NotNull List<T>
getPropertyAsList(@NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration, @NotNull String propertyName, @NotNull Class<T> propertyType)
Returns a given property from the configuration as a list of given type.static @NotNull org.apache.commons.configuration.XMLConfiguration
getXmlConfigFromXmlString(@NotNull String xmlData)
static @NotNull org.apache.commons.configuration.XMLConfiguration
getXmlConfigFromXmlString(@NotNull String xmlData, boolean delimiterParsingDisabled)
Deprecated.since 5.2 use $getXmlConfigFromXmlString(java.lang.String)
static org.apache.commons.configuration.XMLConfiguration
newConfiguration()
static org.apache.commons.configuration.XMLConfiguration
newConfiguration(boolean isDelimiterParsingDisabled)
static org.apache.commons.configuration.XMLConfiguration
newConfiguration(org.apache.commons.configuration.HierarchicalConfiguration configuration)
static void
sanitiseAndSave(@NotNull org.apache.commons.configuration.XMLConfiguration configuration, @NotNull Writer buildXml)
Deprecated.static @NotNull Map<String,Long>
toLongMap(@NotNull Map<String,String> stringMap)
static @NotNull Map<String,String>
toStringMap(@NotNull Map<String,?> objectsMap)
-
-
-
Method Detail
-
copyMapToConfig
public static void copyMapToConfig(@NotNull @NotNull Map<String,String> map, @NotNull @NotNull org.apache.commons.configuration.Configuration config)
-
copyObjectMapToConfig
public static void copyObjectMapToConfig(@NotNull @NotNull Map<String,Object> map, @NotNull @NotNull org.apache.commons.configuration.Configuration config)
-
fromMap
@NotNull public static @NotNull org.apache.commons.configuration.HierarchicalConfiguration fromMap(@NotNull @NotNull Map<String,?> map)
-
fromMap
@NotNull public static <T extends org.apache.commons.configuration.Configuration> T fromMap(@NotNull @NotNull Map<String,?> map, @NotNull @NotNull Supplier<T> configSupplier)
-
asMap
@NotNull public static @NotNull Map<String,String> asMap(@NotNull @NotNull org.apache.commons.configuration.Configuration config)
-
asMap
@NotNull public static @NotNull Map<String,String> asMap(@NotNull @NotNull org.apache.commons.configuration.Configuration config, @Nullable @Nullable String filter)
-
asObjectMap
public static Map<String,Object> asObjectMap(@NotNull @NotNull org.apache.commons.configuration.Configuration config)
-
asObjectMap
@NotNull public static @NotNull Map<String,Object> asObjectMap(@NotNull @NotNull org.apache.commons.configuration.Configuration config, @Nullable @Nullable String filter)
-
addNodesAt
public static void addNodesAt(org.apache.commons.configuration.HierarchicalConfiguration config, String rootPath, org.apache.commons.configuration.HierarchicalConfiguration configToAdd)
-
addNodeAt
public static void addNodeAt(org.apache.commons.configuration.HierarchicalConfiguration configuration, String rootPath, org.apache.commons.configuration.HierarchicalConfiguration configToAdd)
-
addMapToConfiguration
public static void addMapToConfiguration(@NotNull @NotNull String mapConfigKey, @NotNull @NotNull String entryConfigKey, @NotNull @NotNull Map<String,String> map, @NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
-
addMapToConfiguration
public static void addMapToConfiguration(@NotNull @NotNull String mapConfigKey, @NotNull @NotNull Map<String,String> map, @NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
-
addMapToBuilConfiguration
@Deprecated public static void addMapToBuilConfiguration(@NotNull @NotNull String mapKey, @NotNull @NotNull Map<String,String> map, @NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
-
getMapFromConfiguration
@NotNull public static @NotNull Map<String,String> getMapFromConfiguration(@NotNull @NotNull String mapConfigKey, @NotNull @NotNull String entryConfigKey, @NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
-
getMapFromConfiguration
@NotNull public static @NotNull Map<String,String> getMapFromConfiguration(@NotNull @NotNull String mapConfigKey, @NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
-
toStringMap
@NotNull public static @NotNull Map<String,String> toStringMap(@NotNull @NotNull Map<String,?> objectsMap)
-
toLongMap
@NotNull public static @NotNull Map<String,Long> toLongMap(@NotNull @NotNull Map<String,String> stringMap) throws NumberFormatException
- Throws:
NumberFormatException
-
sanitiseAndSave
@Deprecated public static void sanitiseAndSave(@NotNull @NotNull org.apache.commons.configuration.XMLConfiguration configuration, @NotNull @NotNull Writer buildXml) throws org.apache.commons.configuration.ConfigurationException
Deprecated.- Throws:
org.apache.commons.configuration.ConfigurationException
-
asXmlString
@Deprecated public static String asXmlString(@NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration hierarchicalConfiguration)
Deprecated.does not preserve bambooDelimiterParsing disabled property correctly. Avoid, especially when manipulating build configuration. UseBuildConfiguration.asXml()
instead.
-
asXmlString
@NotNull public static @NotNull String asXmlString(@NotNull @NotNull org.apache.commons.configuration.XMLConfiguration configuration)
-
getXmlConfigFromXmlString
@NotNull public static @NotNull org.apache.commons.configuration.XMLConfiguration getXmlConfigFromXmlString(@NotNull @NotNull String xmlData)
-
getXmlConfigFromXmlString
@Deprecated @NotNull public static @NotNull org.apache.commons.configuration.XMLConfiguration getXmlConfigFromXmlString(@NotNull @NotNull String xmlData, boolean delimiterParsingDisabled)
Deprecated.since 5.2 use $getXmlConfigFromXmlString(java.lang.String)
-
copyNodes
public static void copyNodes(@NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration sourceConfig, @NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration targetConfig)
-
copyNodes
public static void copyNodes(@NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration sourceConfig, @NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration targetConfig, @Nullable @Nullable String key)
-
newConfiguration
public static org.apache.commons.configuration.XMLConfiguration newConfiguration()
-
newConfiguration
public static org.apache.commons.configuration.XMLConfiguration newConfiguration(boolean isDelimiterParsingDisabled)
-
newConfiguration
public static org.apache.commons.configuration.XMLConfiguration newConfiguration(org.apache.commons.configuration.HierarchicalConfiguration configuration)
-
getPropertyAsList
@NotNull public static <T> @NotNull List<T> getPropertyAsList(@NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration, @NotNull @NotNull String propertyName, @NotNull @NotNull Class<T> propertyType)
Returns a given property from the configuration as a list of given type. This method acts as a utility to handle cases when the property value is either an iterable, an array, or a single element (in which case a one-element list is returned). If the property is not found in the configuration, an empty list is returned.- Parameters:
configuration
- configuration to fetch propertypropertyName
- name of the propertypropertyType
- expected type of each element from the property value as a list- Returns:
- a list of values of the specified property from the configuration; may be immutable
- Throws:
ClassCastException
- if the provided type is incorrect, e.g. the property is a list, but of a different type
-
getPropertyAsList
@NotNull public static <T> @NotNull List<T> getPropertyAsList(@NotNull @NotNull Map<String,Object> configuration, @NotNull @NotNull String propertyName, @NotNull @NotNull Class<T> propertyType)
Returns a given property from the configuration as a list of given type. This method acts as a utility to handle cases when the property value is either an iterable, an array, or a single element (in which case a one-element list is returned). If the property is not found in the configuration, an empty list is returned.- Parameters:
configuration
- configuration to fetch propertypropertyName
- name of the propertypropertyType
- expected type of each element from the property value as a list- Returns:
- a list of values of the specified property from the configuration; may be immutable
- Throws:
ClassCastException
- if the provided type is incorrect, e.g. the property is a list, but of a different type
-
-