use of org.apache.flink.configuration.description.Description in project plugins by qlangtech.
the class FlinkDescriptor method addFieldDescriptor.
protected void addFieldDescriptor(String fieldName, ConfigOption<?> configOption) {
Description desc = configOption.description();
HtmlFormatter htmlFormatter = new HtmlFormatter();
Object d = configOption.defaultValue();
StringBuffer helperContent = new StringBuffer(htmlFormatter.format(desc));
Class<?> targetClazz = configOption.getClazz();
List<Option> opts = null;
if (targetClazz == Duration.class) {
if (d != null) {
d = ((Duration) d).getSeconds();
}
helperContent.append("\n\n 单位:`秒`");
} else if (targetClazz.isEnum()) {
List<Enum> enums = EnumUtils.getEnumList((Class<Enum>) targetClazz);
opts = enums.stream().map((e) -> new Option(e.name())).collect(Collectors.toList());
} else if (targetClazz == Boolean.class) {
opts = Lists.newArrayList(new Option("是", true), new Option("否", false));
}
this.addFieldDescriptor(fieldName, d, helperContent.toString(), Optional.ofNullable(opts));
}
Aggregations