in flink-ml-servable-core/src/main/java/org/apache/flink/ml/param/WithParams.java [76:109]
default <V> T set(Param<V> param, V value) {
if (!getParamMap().containsKey(param)) {
throw new IllegalArgumentException(
"Parameter "
+ param.name
+ " is not defined on the class "
+ getClass().getName());
}
if (value != null && !param.clazz.isAssignableFrom(value.getClass())) {
throw new ClassCastException(
"Parameter "
+ param.name
+ " is given a value with incompatible class "
+ value.getClass().getName());
}
if (!param.validator.validate(value)) {
if (value == null) {
throw new IllegalArgumentException(
"Parameter " + param.name + "'s value should not be null");
} else {
throw new IllegalArgumentException(
"Parameter "
+ param.name
+ " is given an invalid value "
+ (value.getClass().isArray()
? ArrayUtils.toString(value)
: value));
}
}
getParamMap().put(param, value);
return (T) this;
}