Class ValueProvider
- java.lang.Object
-
- io.fabric8.maven.docker.config.handler.property.ValueProvider
-
public class ValueProvider extends Object
Helper to extract values from a set of Properties, potentially mixing it up with XML-based configuration based on thePropertyModesetting. Obtaining a value is done via data-type specific methods (such asgetString(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. ForPropertyMode.Onlywe only look at the properties, ignoring any config value. ForPropertyMode.Skipwe only look at the config, ignoring any properties value. ForPropertyMode.Overridewe use the property value if it is non-null, else the config value. ForPropertyMode.Fallbackwe 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 theValueCombinePolicydefined in theConfigKey, or as overridden by the property <prefix.someproperty>._combine (EnvUtil.PROPERTY_COMBINE_POLICY_SUFFIX). IfValueCombinePolicy.Replaceis used, only the prioritized value (first non-null) is used. IfValueCombinePolicy.Mergeis 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. *- Author:
- Johan Ström
-
-
Constructor Summary
Constructors Constructor Description ValueProvider(String prefix, Properties properties, PropertyMode propertyMode)Initiates ValueProvider which is to work with data from the given properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BooleangetBoolean(ConfigKey key, Boolean fromConfig)DoublegetDouble(ConfigKey key, Double fromConfig)intgetInt(ConfigKey key, Integer fromConfig)IntegergetInteger(ConfigKey key, Integer fromConfig)List<Integer>getIntList(ConfigKey key, List<Integer> fromConfig)List<String>getList(ConfigKey key, List<String> fromConfig)LonggetLong(ConfigKey key, Long fromConfig)Map<String,String>getMap(ConfigKey key, Map<String,String> fromConfig)List<ValueProvider>getNestedList(ConfigKey key)<T> TgetObject(ConfigKey key, T fromConfig, com.google.common.base.Function<String,T> converter)List<Properties>getPropertiesList(ConfigKey key, List<Properties> fromConfig)StringgetString(ConfigKey key, String fromConfig)
-
-
-
Constructor Detail
-
ValueProvider
public ValueProvider(String prefix, Properties properties, PropertyMode propertyMode)
Initiates ValueProvider which is to work with data from the given properties. The PropertyMode controls which source(s) to consult, and in which order.- Parameters:
prefix- Only look at properties with this prefix.properties-propertyMode- Which source to prioritize
-
-
Method Detail
-
getPropertiesList
public List<Properties> getPropertiesList(ConfigKey key, List<Properties> fromConfig)
-
getObject
public <T> T getObject(ConfigKey key, T fromConfig, com.google.common.base.Function<String,T> converter)
-
getNestedList
public List<ValueProvider> getNestedList(ConfigKey key)
-
-