T getFromPreferredSource(String prefix, ConfigKey key, T fromConfig) {
            if(propertyMode == PropertyMode.Skip) {
                return fromConfig;
            }

            List<T> values = new ArrayList<>();

            // Find all non-null values, put into "values" with order based on the given propertyMode
            T fromProperty = withPrefix(prefix, key, properties);

            // Short-circuit
            if(fromProperty == null && fromConfig == null) {
                return null;
            }

            switch (propertyMode) {
                case Only:
                    return fromProperty;
                case Override:
                    if(fromProperty != null) {
                        values.add(fromProperty);
                    }
                    if(fromConfig != null) {
                        values.add(fromConfig);
                    }
                    break;
                case Fallback:
                    if(fromConfig != null) {
                        values.add(fromConfig);
                    }
                    if(fromProperty != null) {
                        values.add(fromProperty);
                    }
                    break;
                default:
                    throw new AssertionError("Invalid PropertyMode");
            }

            if(values.size() == 1) {
                return values.get(0);
            }

            // values now has non-null values from both sources, in preference order.
            // Let's merge according to the combine policy
            ValueCombinePolicy combinePolicy = key.getValueCombinePolicy();
            String overrideCombinePolicy = properties.getProperty(key.asPropertyKey(prefix) + "." + EnvUtil.PROPERTY_COMBINE_POLICY_SUFFIX);
            if(overrideCombinePolicy != null) {
                combinePolicy = ValueCombinePolicy.fromString(overrideCombinePolicy);
            }

            switch(combinePolicy) {
                case Replace:
                    return values.get(0);
                case Merge:
                    return merge(key, values);
            }
            return null;
        }
Helper base class for picking values out of the Properties class and/or config value.

If there is only one source defined, we only use that. If multiple source are defined, the first one has priority.
If more than one value is specified, a merge policy as specified for the ConfigKey
src/main/java/io/fabric8/maven/docker/config/handler/property/ValueProvider.java