walterddr commented on a change in pull request #8402: [FLINK-12473][ml] Add the interface of ML pipeline and ML lib URL: https://github.com/apache/flink/pull/8402#discussion_r283117478
########## File path: flink-ml/flink-ml-api/src/main/java/org/apache/flink/ml/api/misc/param/ParamInfo.java ########## @@ -0,0 +1,145 @@ +/* + * 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.flink.ml.api.misc.param; + +import org.apache.flink.annotation.PublicEvolving; + +/** + * Definition of a parameter, including name, type, default value, validator and so on. + * + * <p>This class is provided to unify the interaction with parameters. + * + * @param <V> the type of the param value + */ +@PublicEvolving +public class ParamInfo<V> { + private final String name; + private final String description; + private final boolean isOptional; + private final boolean hasDefaultValue; + private final V defaultValue; + private final ParamValidator<V> validator; + private final Class<V> valueClass; + + public ParamInfo(String name, String description, Class<V> valueClass) { + this(name, description, true, false, null, null, valueClass); + } + + public ParamInfo(String name, String description, V defaultValue, Class<V> valueClass) { + this(name, description, true, true, defaultValue, null, valueClass); + } + + public ParamInfo(String name, String description, boolean isOptional, Class<V> valueClass) { + this(name, description, isOptional, false, null, null, valueClass); + } + + public ParamInfo(String name, String description, boolean isOptional, V defaultValue, Class<V> valueClass) { + this(name, description, isOptional, true, defaultValue, null, valueClass); + } + + public ParamInfo(String name, String description, boolean isOptional, V defaultValue, ParamValidator<V> validator, Class<V> valueClass) { + this(name, description, isOptional, true, defaultValue, validator, valueClass); + } + + private ParamInfo(String name, String description, boolean isOptional, boolean hasDefaultValue, V defaultValue, ParamValidator<V> validator, Class<V> valueClass) { + this.name = name; + this.description = description; + this.isOptional = isOptional; + this.hasDefaultValue = hasDefaultValue; + this.defaultValue = defaultValue; + this.validator = validator; + this.valueClass = valueClass; + } + + /** + * Returns the name of the parameter. Review comment: might be good to explain `name` needs to be unique within a pipeline (since it is used for the paramMap as key) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
