/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.spring.boot.util;

import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.core.env.Environment;

public final class HierarchicalPropertiesEvaluator {
    private HierarchicalPropertiesEvaluator() {
    }

    public static boolean evaluate(Environment environment, String... prefixes) {
        boolean answer = true;

        for (String prefix : prefixes) {
            answer = isEnabled(environment, prefix, answer);
        }

        return answer;
    }

    private static boolean isEnabled(Environment environment, String prefix, boolean defaultValue) {
        RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            environment,
            prefix.endsWith(".") ? prefix : prefix + "."
        );

        return resolver.getProperty("enabled", Boolean.class, defaultValue);
    }
}

@@ -1069,158 +1069,779 @@
     
-public static boolean evaluate(Environment environment, String... prefixes) %7B%0A        boolean answer = true;%0A%0A        for (String prefix : prefixes) %7B
+/**%0A     * Determine the value of the %22enabled%22 flag for a hierarchy of properties.%0A     *%0A     * @param environment the environment%0A     * @param prefixes an ordered list of prefixed (less restrictive to more restrictive)%0A     * @return the value of the key %60enabled%60 for most restrictive prefix%0A     */%0A    public static boolean evaluate(Environment environment, String... prefixes) %7B%0A        boolean answer = true;%0A%0A        // Loop over all the prefixes to find out the value of the key %60enabled%60%0A        // for the most restrictive prefix.%0A        for (String prefix : prefixes) %7B%0A            // evaluate the value of the current prefix using the parent one%0A            // as default value so if the enabled property is not set, the parent%0A            // one is used.
 %0A   

Add documentation for HierarchicalPropertiesEvaluator