THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Page properties | |
---|---|
|
...
...
...
...
|
...
|
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
...
3) The ParamInfoFactory class provides APIs to build a ParamInfo.
Code Block | ||
---|---|---|
| ||
public class ParamInfoFactory {
public static <V> ParamInfoBuilder<V> createParamInfo(String name, Class<V> valueClass) {...}
public static class ParamInfoBuilder<V> {
ParamInfoBuilder(String name, Class<V> valueClass) {...}
public ParamInfoBuilder<V> setAlias(String[] alias) {...}
public ParamInfoBuilder<V> setDescription(String description) {...}
public ParamInfoBuilder<V> setOptional() {...}
public ParamInfoBuilder<V> setRequired() {...}
public ParamInfoBuilder<V> setHasDefaultValue(V defaultValue) {...}
public ParamInfoBuilder<V> setValidator(ParamValidator<V> validator) {...}
public ParamInfo<V> build() {...}
}
} |
...
Code Block | ||
---|---|---|
| ||
/** * Interface for classes that take parameters. It provides APIs to set and get parameters. * * @param <T> The class type of WithParams implementation itself. */ @PublicEvolving public interface WithParams<T> { /** * Gets athe paramparameter by its name. */ default <V>* Param<V>@param getParam(String name) {...} name The parameter name. /** @param <V> The class *type Setsof the parameter value. of the given parameter in* the@return user-definedThe mapparameter. */ default *<V> @paramParam<V> param the parametergetParam(String name) {...} * @param value the value/** * @returnSets the WithParamsvalue of instancethe itselfparameter. */ default <V> T set(Param<V>* @param param, V value) {...} The parameter. /*** @param value The parameter value. * Gets@return theThe valueWithParams of the given parameter. Returns the value from the user-defined map if set(...) has beeninstance itself. */ @SuppressWarnings("unchecked") default *<V> explicitlyT called to setset(Param<V> param, V value for this parameter. Otherwise, returns the default value from the definition of * this ) {...} /** * Gets the value of the parameter. * * @param param theThe parameter. * @param <V> theThe class type of the parameter value. * @return theThe parameter value. of the parameter*/ */@SuppressWarnings("unchecked") default <V> V get(Param<V> param) {...} /** * Returns a map which should contain value for every parameter that meets one of the following * conditions. * * <p>1) set(...) has been called to set value for this parameter. * * <p>2) The parameter is a public final field of this WithParams instance. This includes fields * inherited from its interfaces and super-classes. * * <p>The subclass which implements this interface could meet this requirement by returning a * member field of the given map type, after having initialized this member field using the * {@link ParamUtils#initializeMapWithDefaultValues(Map, WithParams)} method. * * @return A map which maps parameter definition to parameter value. */ Map<Param<?>, Object> getParamMap(); } |
2) We propose to add the following subclasses of Param<?> to simplify the creation of parameters with primitive-typed values (e.g. long, int, boolean).
Code Block | ||
---|---|---|
| ||
public class BooleanParam extends Param<Boolean> {
...
}
public class IntParam extends Param<Integer> {
...
}
public class LongParam extends Param<Long> {
...
}
public class FloatParam extends Param<Float> {
...
}
public class DoubleParam extends Param<Double> {
...
}
public class StringParam extends Param<String> {
...
}
public class IntArrayParam extends Param<Integer[]> {
...
}
public class LongArrayParam extends Param<Long[]> {
...
}
public class FloatArrayParam extends Param<Float[]> {
...
}
public class DoubleArrayParam extends Param<Double[]> {
...
}
|
...