public class ValueProvider extends Object
PropertyMode
setting.
Obtaining a value is done via data-type specific methods (such as getString(io.fabric8.maven.docker.config.handler.property.ConfigKey, java.lang.String)
). The ConfigKey parameter
tells us which property to look for, and how to handle combination of multiple values.
For PropertyMode.Only
we only look at the properties, ignoring any config value.
For PropertyMode.Skip
we only look at the config, ignoring any properties value.
For PropertyMode.Override
we use the property value if it is non-null, else the config value.
For PropertyMode.Fallback
we use the config value if it is non-null, else the property value.
For Override and Fallback mode, merging may take place as dictated by the ValueCombinePolicy
defined in the ConfigKey
, or as overriden by the property <prefix.someproperty>._combine
(EnvUtil.PROPERTY_COMBINE_POLICY_SUFFIX
).
If ValueCombinePolicy.Replace
is used, only the prioritized value (first non-null) is used.
If ValueCombinePolicy.Merge
is used, the merge method depends on the data type.
For simple types (string, int, long, boolean) this is not supported and will throw exception.
For Lists, the non-null values will be appended to each other (with values from first source added first)
For Maps, all maps are merged into one map, with data from the first map taking precedence. *Constructor and Description |
---|
ValueProvider(String prefix,
Properties properties,
PropertyMode propertyMode)
Initiates ValueProvider which is to work with data from the given properties.
|
Modifier and Type | Method and Description |
---|---|
Boolean |
getBoolean(ConfigKey key,
Boolean fromConfig) |
Double |
getDouble(ConfigKey key,
Double fromConfig) |
int |
getInt(ConfigKey key,
Integer fromConfig) |
Integer |
getInteger(ConfigKey key,
Integer fromConfig) |
List<Integer> |
getIntList(ConfigKey key,
List<Integer> fromConfig) |
List<String> |
getList(ConfigKey key,
List<String> fromConfig) |
Long |
getLong(ConfigKey key,
Long fromConfig) |
Map<String,String> |
getMap(ConfigKey key,
Map<String,String> fromConfig) |
<T> T |
getObject(ConfigKey key,
T fromConfig,
com.google.common.base.Function<String,T> converter) |
String |
getString(ConfigKey key,
String fromConfig) |
public ValueProvider(String prefix, Properties properties, PropertyMode propertyMode)
prefix
- Only look at properties with this prefix.properties
- propertyMode
- Which source to prioritizeCopyright © 2021. All rights reserved.