...
...
...
...
| Jira |
---|
server | ASF JIRA |
---|
serverId | 5aa69414-a9e9-3523-82ec-879b028fb15b |
---|
key | FLINK-24354 |
---|
|
|
---|
|
...
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
a param by name. */
Gets the parameter defaultby <V> Param<V> getParam(String name) {...}
its name.
/**
* Sets@param thename value of the given parameter in the user-defined mapThe parameter name.
*
@param <V> The class *type @paramof param the parameter
* @param value the valuevalue.
* @return the WithParams instance itselfThe parameter.
*/
default <V> TParam<V> setgetParam(Param<V> param, V valueString name) {...}
/**
* GetsSets the value of the given parameter.
Returns the value from the user-defined map if set(...) has been *
* @param param The parameter.
* @param value The parameter value.
* @return The WithParams instance itself.
*/
* explicitly called to set value for this parameter. Otherwise, returns the default value from the definition of
* this @SuppressWarnings("unchecked")
default <V> T set(Param<V> param, V value) {...}
/**
* 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[]> {
...
}
|
...