HBASE-17563 Changed for-loops and switch-statements in RootDocProcessor and StabilityOptions

Signed-off-by: Michael Stack <stack@apache.org>
This commit is contained in:
Jan Hentschel 2017-01-27 23:20:09 +01:00 committed by Michael Stack
parent 3693d1306d
commit 87e1ba9a1a
2 changed files with 55 additions and 45 deletions

View File

@ -107,44 +107,47 @@ final class RootDocProcessor {
return !exclude(doc) && doc.isIncluded(); return !exclude(doc) && doc.isIncluded();
} }
if (target instanceof RootDoc) { if (target instanceof RootDoc) {
if (methodName.equals("classes")) { switch (methodName) {
return filter(((RootDoc) target).classes(), ClassDoc.class); case "classes":
} else if (methodName.equals("specifiedClasses")) { return filter(((RootDoc) target).classes(), ClassDoc.class);
return filter(((RootDoc) target).specifiedClasses(), ClassDoc.class); case "specifiedClasses":
} else if (methodName.equals("specifiedPackages")) { return filter(((RootDoc) target).specifiedClasses(), ClassDoc.class);
return filter(((RootDoc) target).specifiedPackages(), PackageDoc.class); case "specifiedPackages":
return filter(((RootDoc) target).specifiedPackages(), PackageDoc.class);
} }
} else if (target instanceof ClassDoc) { } else if (target instanceof ClassDoc) {
if (isFiltered(args)) { if (isFiltered(args)) {
if (methodName.equals("methods")) { switch (methodName) {
return filter(((ClassDoc) target).methods(true), MethodDoc.class); case "methods":
} else if (methodName.equals("fields")) { return filter(((ClassDoc) target).methods(true), MethodDoc.class);
return filter(((ClassDoc) target).fields(true), FieldDoc.class); case "fields":
} else if (methodName.equals("innerClasses")) { return filter(((ClassDoc) target).fields(true), FieldDoc.class);
return filter(((ClassDoc) target).innerClasses(true), ClassDoc.class); case "innerClasses":
} else if (methodName.equals("constructors")) { return filter(((ClassDoc) target).innerClasses(true), ClassDoc.class);
return filter(((ClassDoc) target).constructors(true), ConstructorDoc.class); case "constructors":
return filter(((ClassDoc) target).constructors(true), ConstructorDoc.class);
} }
} }
} else if (target instanceof PackageDoc) { } else if (target instanceof PackageDoc) {
if (methodName.equals("allClasses")) { switch (methodName) {
if (isFiltered(args)) { case "allClasses":
return filter(((PackageDoc) target).allClasses(true), ClassDoc.class); if (isFiltered(args)) {
} else { return filter(((PackageDoc) target).allClasses(true), ClassDoc.class);
return filter(((PackageDoc) target).allClasses(), ClassDoc.class); } else {
} return filter(((PackageDoc) target).allClasses(), ClassDoc.class);
} else if (methodName.equals("annotationTypes")) { }
return filter(((PackageDoc) target).annotationTypes(), AnnotationTypeDoc.class); case "annotationTypes":
} else if (methodName.equals("enums")) { return filter(((PackageDoc) target).annotationTypes(), AnnotationTypeDoc.class);
return filter(((PackageDoc) target).enums(), ClassDoc.class); case "enums":
} else if (methodName.equals("errors")) { return filter(((PackageDoc) target).enums(), ClassDoc.class);
return filter(((PackageDoc) target).errors(), ClassDoc.class); case "errors":
} else if (methodName.equals("exceptions")) { return filter(((PackageDoc) target).errors(), ClassDoc.class);
return filter(((PackageDoc) target).exceptions(), ClassDoc.class); case "exceptions":
} else if (methodName.equals("interfaces")) { return filter(((PackageDoc) target).exceptions(), ClassDoc.class);
return filter(((PackageDoc) target).interfaces(), ClassDoc.class); case "interfaces":
} else if (methodName.equals("ordinaryClasses")) { return filter(((PackageDoc) target).interfaces(), ClassDoc.class);
return filter(((PackageDoc) target).ordinaryClasses(), ClassDoc.class); case "ordinaryClasses":
return filter(((PackageDoc) target).ordinaryClasses(), ClassDoc.class);
} }
} }
} }

View File

@ -40,25 +40,32 @@ final class StabilityOptions {
} }
public static void validOptions(String[][] options, DocErrorReporter reporter) { public static void validOptions(String[][] options, DocErrorReporter reporter) {
for (int i = 0; i < options.length; i++) { for (String[] option : options) {
String opt = options[i][0].toLowerCase(Locale.ROOT); String opt = option[0].toLowerCase(Locale.ROOT);
if (opt.equals(UNSTABLE_OPTION)) { switch (opt) {
RootDocProcessor.stability = UNSTABLE_OPTION; case UNSTABLE_OPTION:
} else if (opt.equals(EVOLVING_OPTION)) { RootDocProcessor.stability = UNSTABLE_OPTION;
RootDocProcessor.stability = EVOLVING_OPTION; break;
} else if (opt.equals(STABLE_OPTION)) { case EVOLVING_OPTION:
RootDocProcessor.stability = STABLE_OPTION; RootDocProcessor.stability = EVOLVING_OPTION;
break;
case STABLE_OPTION:
RootDocProcessor.stability = STABLE_OPTION;
break;
default:
RootDocProcessor.stability = UNSTABLE_OPTION;
break;
} }
} }
} }
public static String[][] filterOptions(String[][] options) { public static String[][] filterOptions(String[][] options) {
List<String[]> optionsList = new ArrayList<>(); List<String[]> optionsList = new ArrayList<>();
for (int i = 0; i < options.length; i++) { for (String[] option : options) {
if (!options[i][0].equalsIgnoreCase(UNSTABLE_OPTION) if (!option[0].equalsIgnoreCase(UNSTABLE_OPTION)
&& !options[i][0].equalsIgnoreCase(EVOLVING_OPTION) && !option[0].equalsIgnoreCase(EVOLVING_OPTION)
&& !options[i][0].equalsIgnoreCase(STABLE_OPTION)) { && !option[0].equalsIgnoreCase(STABLE_OPTION)) {
optionsList.add(options[i]); optionsList.add(option);
} }
} }
String[][] filteredOptions = new String[optionsList.size()][]; String[][] filteredOptions = new String[optionsList.size()][];