lindong28 commented on a change in pull request #10: URL: https://github.com/apache/flink-ml/pull/10#discussion_r744420186
########## File path: flink-ml-api/src/main/java/org/apache/flink/ml/param/Param.java ########## @@ -0,0 +1,98 @@ +/* + * 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.param; + +import org.apache.flink.annotation.PublicEvolving; +import org.apache.flink.ml.util.ReadWriteUtils; + +import java.io.IOException; +import java.io.Serializable; + +/** + * Definition of a parameter, including name, class, description, default value and the validator. + * + * @param <T> The class type of the parameter value. + */ +@PublicEvolving +public class Param<T> implements Serializable { + private static final long serialVersionUID = 4396556083935765299L; + + public final String name; + public final Class<T> clazz; + public final String description; + public final T defaultValue; + public final ParamValidator<T> validator; + + public Param( + String name, + Class<T> clazz, + String description, + T defaultValue, + ParamValidator<T> validator) { + this.name = name; + this.clazz = clazz; + this.description = description; + this.defaultValue = defaultValue; + this.validator = validator; + + if (defaultValue != null && !validator.validate(defaultValue)) { Review comment: Discussed offline. We agreed to keep the check as it is. The reason is that we want to allow users not to set the default value (e.g. defaultValue = null) in the parameter definition and still be able to specify a validator which requires the parameter value to be not-null. Note that the check is useful here in case users specify a not-null default value that does not meet the validator requirement. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
