io.inverno.mod.configuration.ExecutableConfigurationQuery Maven / Gradle / Ivy
Show all versions of inverno-configuration Show documentation
/*
* Copyright 2020 Jeremy KUHN
*
* Licensed 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 io.inverno.mod.configuration;
import io.inverno.mod.configuration.ConfigurationKey.Parameter;
import java.util.Arrays;
import java.util.List;
import reactor.core.publisher.Flux;
/**
*
* An executable configuration query can be executed to retrieve configuration properties defined for a particular context from a configuration source.
*
*
*
* Multiple configuration queries can be chained by calling the {@link ExecutableConfigurationQuery#and} method to be executed in a batch when the {@link ExecutableConfigurationQuery#execute} method
* is invoked on the last query.
*
*
* @author Jeremy Kuhn
* @since 1.0
*
* @see ConfigurationQuery
* @see ConfigurationQueryResult
*
* @param the query type
* @param the executable query type
*/
public interface ExecutableConfigurationQuery, B extends ExecutableConfigurationQuery> {
/**
*
* Defines one parameter that specifies the context in which configuration properties are to be retrieved.
*
*
* @param k1 the parameter name
* @param v1 the parameter value
*
* @return the executable configuration query
*/
default B withParameters(String k1, Object v1) {
return this.withParameters(List.of(Parameter.of(k1, v1)));
}
/**
*
* Defines two parameters that specify the context in which configuration properties are to be retrieved.
*
*
* @param k1 the first parameter name
* @param v1 the first parameter value
* @param k2 the second parameter name
* @param v2 the second parameter value
*
* @return the executable configuration query
*
* @throws IllegalArgumentException if parameters were specified more than once
*/
default B withParameters(String k1, Object v1, String k2, Object v2) throws IllegalArgumentException {
return this.withParameters(List.of(Parameter.of(k1, v1), Parameter.of(k2, v2)));
}
/**
*
* Defines three parameters that specify the context in which configuration properties are to be retrieved.
*
*
* @param k1 the first parameter name
* @param v1 the first parameter value
* @param k2 the second parameter name
* @param v2 the second parameter value
* @param k3 the third parameter name
* @param v3 the third parameter value
*
* @return the executable configuration query
*
* @throws IllegalArgumentException if parameters were specified more than once
*/
default B withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3) throws IllegalArgumentException {
return this.withParameters(List.of(Parameter.of(k1, v1), Parameter.of(k2, v2), Parameter.of(k3, v3)));
}
/**
*
* Defines four parameters that specify the context in which configuration properties are to be retrieved.
*
*
* @param k1 the first parameter name
* @param v1 the first parameter value
* @param k2 the second parameter name
* @param v2 the second parameter value
* @param k3 the third parameter name
* @param v3 the third parameter value
* @param k4 the fourth parameter name
* @param v4 the fourth parameter value
*
* @return the executable configuration query
*
* @throws IllegalArgumentException if parameters were specified more than once
*/
default B withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4) throws IllegalArgumentException {
return this.withParameters(List.of(Parameter.of(k1, v1), Parameter.of(k2, v2), Parameter.of(k3, v3), Parameter.of(k4, v4)));
}
/**
*
* Defines five parameters that specify the context in which configuration properties are to be retrieved.
*
*
* @param k1 the first parameter name
* @param v1 the first parameter value
* @param k2 the second parameter name
* @param v2 the second parameter value
* @param k3 the third parameter name
* @param v3 the third parameter value
* @param k4 the fourth parameter name
* @param v4 the fourth parameter value
* @param k5 the fifth parameter name
* @param v5 the fifth parameter value
*
* @return the executable configuration query
*
* @throws IllegalArgumentException if parameters were specified more than once
*/
default B withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5) throws IllegalArgumentException {
return this.withParameters(List.of(Parameter.of(k1, v1), Parameter.of(k2, v2), Parameter.of(k3, v3), Parameter.of(k4, v4), Parameter.of(k5, v5)));
}
/**
*
* Defines six parameters that specify the context in which configuration properties are to be retrieved.
*
*
* @param k1 the first parameter name
* @param v1 the first parameter value
* @param k2 the second parameter name
* @param v2 the second parameter value
* @param k3 the third parameter name
* @param v3 the third parameter value
* @param k4 the fourth parameter name
* @param v4 the fourth parameter value
* @param k5 the fifth parameter name
* @param v5 the fifth parameter value
* @param k6 the sixth parameter name
* @param v6 the sixth parameter value
*
* @return the executable configuration query
*
* @throws IllegalArgumentException if parameters were specified more than once
*/
default B withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6) throws IllegalArgumentException {
return this.withParameters(List.of(Parameter.of(k1, v1), Parameter.of(k2, v2), Parameter.of(k3, v3), Parameter.of(k4, v4), Parameter.of(k5, v5), Parameter.of(k6, v6)));
}
/**
*
* Defines seven parameters that specify the context in which configuration properties are to be retrieved.
*
*
* @param k1 the first parameter name
* @param v1 the first parameter value
* @param k2 the second parameter name
* @param v2 the second parameter value
* @param k3 the third parameter name
* @param v3 the third parameter value
* @param k4 the fourth parameter name
* @param v4 the fourth parameter value
* @param k5 the fifth parameter name
* @param v5 the fifth parameter value
* @param k6 the sixth parameter name
* @param v6 the sixth parameter value
* @param k7 the seventh parameter name
* @param v7 the seventh parameter value
*
* @return the executable configuration query
*
* @throws IllegalArgumentException if parameters were specified more than once
*/
default B withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7) throws IllegalArgumentException {
return this.withParameters(List.of(Parameter.of(k1, v1), Parameter.of(k2, v2), Parameter.of(k3, v3), Parameter.of(k4, v4), Parameter.of(k5, v5), Parameter.of(k6, v6), Parameter.of(k7, v7)));
}
/**
*
* Defines eigth parameters that specify the context in which configuration properties are to be retrieved.
*
*
* @param k1 the first parameter name
* @param v1 the first parameter value
* @param k2 the second parameter name
* @param v2 the second parameter value
* @param k3 the third parameter name
* @param v3 the third parameter value
* @param k4 the fourth parameter name
* @param v4 the fourth parameter value
* @param k5 the fifth parameter name
* @param v5 the fifth parameter value
* @param k6 the sixth parameter name
* @param v6 the sixth parameter value
* @param k7 the seventh parameter name
* @param v7 the seventh parameter value
* @param k8 the eighth parameter name
* @param v8 the eighth parameter value
*
* @return the executable configuration query
*
* @throws IllegalArgumentException if parameters were specified more than once
*/
default B withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7, String k8, Object v8) throws IllegalArgumentException {
return this.withParameters(List.of(Parameter.of(k1, v1), Parameter.of(k2, v2), Parameter.of(k3, v3), Parameter.of(k4, v4), Parameter.of(k5, v5), Parameter.of(k6, v6), Parameter.of(k7, v7), Parameter.of(k8, v8)));
}
/**
*
* Defines nine parameters that specify the context in which configuration properties are to be retrieved.
*
*
* @param k1 the first parameter name
* @param v1 the first parameter value
* @param k2 the second parameter name
* @param v2 the second parameter value
* @param k3 the third parameter name
* @param v3 the third parameter value
* @param k4 the fourth parameter name
* @param v4 the fourth parameter value
* @param k5 the fifth parameter name
* @param v5 the fifth parameter value
* @param k6 the sixth parameter name
* @param v6 the sixth parameter value
* @param k7 the seventh parameter name
* @param v7 the seventh parameter value
* @param k8 the eighth parameter name
* @param v8 the eighth parameter value
* @param k9 the ninth parameter name
* @param v9 the ninth parameter value
*
* @return the executable configuration query
*
* @throws IllegalArgumentException if parameters were specified more than once
*/
default B withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7, String k8, Object v8, String k9, Object v9) throws IllegalArgumentException {
return this.withParameters(List.of(Parameter.of(k1, v1), Parameter.of(k2, v2), Parameter.of(k3, v3), Parameter.of(k4, v4), Parameter.of(k5, v5), Parameter.of(k6, v6), Parameter.of(k7, v7), Parameter.of(k8, v8), Parameter.of(k9, v9)));
}
/**
*
* Defines ten parameters that specify the context in which configuration properties are to be retrieved.
*
*
* @param k1 the first parameter name
* @param v1 the first parameter value
* @param k2 the second parameter name
* @param v2 the second parameter value
* @param k3 the third parameter name
* @param v3 the third parameter value
* @param k4 the fourth parameter name
* @param v4 the fourth parameter value
* @param k5 the fifth parameter name
* @param v5 the fifth parameter value
* @param k6 the sixth parameter name
* @param v6 the sixth parameter value
* @param k7 the seventh parameter name
* @param v7 the seventh parameter value
* @param k8 the eighth parameter name
* @param v8 the eighth parameter value
* @param k9 the ninth parameter name
* @param v9 the ninth parameter value
* @param k10 the tenth parameter name
* @param v10 the tenth parameter value
*
* @return the executable configuration query
*
* @throws IllegalArgumentException if parameters were specified more than once
*/
default B withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7, String k8, Object v8, String k9, Object v9, String k10, Object v10) throws IllegalArgumentException {
return this.withParameters(List.of(Parameter.of(k1, v1), Parameter.of(k2, v2), Parameter.of(k3, v3), Parameter.of(k4, v4), Parameter.of(k5, v5), Parameter.of(k6, v6), Parameter.of(k7, v7), Parameter.of(k8, v8), Parameter.of(k9, v9), Parameter.of(k10, v10)));
}
/**
*
* Defines parameters that specify the context in which configuration properties are to be retrieved.
*
*
* @param parameters an array of parameters
*
* @return the executable configuration query
*
* @throws IllegalArgumentException if parameters were specified more than once
*/
default B withParameters(Parameter... parameters) throws IllegalArgumentException {
return this.withParameters(parameters != null ? Arrays.asList(parameters) : List.of());
}
/**
*
* Defines parameters that specify the context in which configuration properties are to be retrieved.
*
*
* @param parameters a list of parameters
*
* @return the executable configuration query
*
* @throws IllegalArgumentException if parameters were specified more than once
*/
B withParameters(List parameters) throws IllegalArgumentException;
/**
*
* Chains another query.
*
*
* @return a configuration query
*/
A and();
/**
*
* Executes the chain of configuration queries.
*
*
*
* Results are emitted in the same order as the queries.
*
*
* @return a stream of configuration query results
*/
Flux execute();
}