Skip to content

Commit

Permalink
[hotfix][conf][tests] Introduce factory method
Browse files Browse the repository at this point in the history
  • Loading branch information
zentol committed Jan 18, 2020
1 parent 1ffa299 commit ab6b359
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,10 @@ private static Map<String, ExistingOption> findExistingOptions(Predicate<ConfigO
List<ConfigOptionsDocGenerator.OptionWithMetaInfo> configOptions = extractConfigOptions(optionsClass);
for (ConfigOptionsDocGenerator.OptionWithMetaInfo option : configOptions) {
if (predicate.test(option)) {
String key = option.option.key();
String defaultValue = stringifyDefault(option);
String typeValue = typeToHtml(option);
String description = htmlFormatter.format(option.option.description());
ExistingOption newOption = toExistingOption(option, optionsClass)
ExistingOption duplicate = existingOptions.put(
key,
new ExistingOption(key, defaultValue, typeValue, description, optionsClass));
newOption.key,
newOption);
if (duplicate != null) {
// multiple documented options have the same key
// we fail here outright as this is not a documentation-completeness problem
Expand All @@ -228,6 +225,13 @@ private static Map<String, ExistingOption> findExistingOptions(Predicate<ConfigO
}

return existingOptions;

private static ExistingOption toExistingOption(ConfigOptionsDocGenerator.OptionWithMetaInfo optionWithMetaInfo, Class<?> optionsClass) {
String key = optionWithMetaInfo.option.key();
String defaultValue = stringifyDefault(optionWithMetaInfo);
String typeValue = typeToHtml(optionWithMetaInfo);
String description = htmlFormatter.format(optionWithMetaInfo.option.description());
return new ExistingOption(key, defaultValue, typeValue, description, optionsClass);
}

private static final class ExistingOption extends Option {
Expand Down

0 comments on commit ab6b359

Please sign in to comment.