yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [3/8] yetus git commit: YETUS-539. Changed for-loops and switch-statements in RootDocProcessor and StabilityOptions
Date Wed, 17 Jan 2018 16:19:33 GMT
YETUS-539. Changed for-loops and switch-statements in RootDocProcessor and StabilityOptions

Signed-off-by: Allen Wittenauer <aw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/ad2f57f0
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/ad2f57f0
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/ad2f57f0

Branch: refs/heads/YETUS-585
Commit: ad2f57f08e444bb5b92bc560886471b3dc3e3e2e
Parents: a74b317
Author: Jan Hentschel <jan.hentschel@ultratendency.com>
Authored: Wed Dec 27 21:11:59 2017 +0100
Committer: Allen Wittenauer <aw@apache.org>
Committed: Mon Jan 15 10:49:41 2018 -0800

----------------------------------------------------------------------
 .../yetus/audience/tools/RootDocProcessor.java  | 85 ++++++++++----------
 .../yetus/audience/tools/StabilityOptions.java  | 30 ++++---
 2 files changed, 61 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/ad2f57f0/audience-annotations-component/audience-annotations/src/main/java/org/apache/yetus/audience/tools/RootDocProcessor.java
----------------------------------------------------------------------
diff --git a/audience-annotations-component/audience-annotations/src/main/java/org/apache/yetus/audience/tools/RootDocProcessor.java
b/audience-annotations-component/audience-annotations/src/main/java/org/apache/yetus/audience/tools/RootDocProcessor.java
index 46d7fac..fe3e858 100644
--- a/audience-annotations-component/audience-annotations/src/main/java/org/apache/yetus/audience/tools/RootDocProcessor.java
+++ b/audience-annotations-component/audience-annotations/src/main/java/org/apache/yetus/audience/tools/RootDocProcessor.java
@@ -107,53 +107,56 @@ class RootDocProcessor {
           return !exclude(doc) && doc.isIncluded();
         }
         if (target instanceof RootDoc) {
-          if (methodName.equals("classes")) {
-            return filter(((RootDoc) target).classes(), ClassDoc.class);
-          } else if (methodName.equals("specifiedClasses")) {
-            return filter(((RootDoc) target).specifiedClasses(), ClassDoc.class);
-          } else if (methodName.equals("specifiedPackages")) {
-            return filter(((RootDoc) target).specifiedPackages(), PackageDoc.class);
+          switch (methodName) {
+            case "classes":
+              return filter(((RootDoc) target).classes(), ClassDoc.class);
+            case "specifiedClasses":
+              return filter(((RootDoc) target).specifiedClasses(), ClassDoc.class);
+            case "specifiedPackages":
+              return filter(((RootDoc) target).specifiedPackages(), PackageDoc.class);
           }
         } else if (target instanceof ClassDoc) {
           if (isFiltered(args)) {
-            if (methodName.equals("methods")) {
-              return filter(((ClassDoc) target).methods(true), MethodDoc.class);
-            } else if (methodName.equals("fields")) {
-              return filter(((ClassDoc) target).fields(true), FieldDoc.class);
-            } else if (methodName.equals("innerClasses")) {
-              return filter(((ClassDoc) target).innerClasses(true),
-                  ClassDoc.class);
-            } else if (methodName.equals("constructors")) {
-              return filter(((ClassDoc) target).constructors(true),
-                  ConstructorDoc.class);
+            switch (methodName) {
+              case "methods":
+                return filter(((ClassDoc) target).methods(true), MethodDoc.class);
+              case "fields":
+                return filter(((ClassDoc) target).fields(true), FieldDoc.class);
+              case "innerClasses":
+                return filter(((ClassDoc) target).innerClasses(true),
+                        ClassDoc.class);
+              case "constructors":
+                return filter(((ClassDoc) target).constructors(true),
+                        ConstructorDoc.class);
             }
           }
         } else if (target instanceof PackageDoc) {
-          if (methodName.equals("allClasses")) {
-            if (isFiltered(args)) {
-              return filter(((PackageDoc) target).allClasses(true),
-                  ClassDoc.class);
-            } else {
-              return filter(((PackageDoc) target).allClasses(), ClassDoc.class);
-            }
-          } else if (methodName.equals("annotationTypes")) {
-            return filter(((PackageDoc) target).annotationTypes(),
-                AnnotationTypeDoc.class);
-          } else if (methodName.equals("enums")) {
-            return filter(((PackageDoc) target).enums(),
-                ClassDoc.class);
-          } else if (methodName.equals("errors")) {
-            return filter(((PackageDoc) target).errors(),
-                ClassDoc.class);
-          } else if (methodName.equals("exceptions")) {
-            return filter(((PackageDoc) target).exceptions(),
-                ClassDoc.class);
-          } else if (methodName.equals("interfaces")) {
-            return filter(((PackageDoc) target).interfaces(),
-                ClassDoc.class);
-          } else if (methodName.equals("ordinaryClasses")) {
-            return filter(((PackageDoc) target).ordinaryClasses(),
-                ClassDoc.class);
+          switch (methodName) {
+            case "allClasses":
+              if (isFiltered(args)) {
+                return filter(((PackageDoc) target).allClasses(true),
+                        ClassDoc.class);
+              } else {
+                return filter(((PackageDoc) target).allClasses(), ClassDoc.class);
+              }
+            case "annotationTypes":
+              return filter(((PackageDoc) target).annotationTypes(),
+                      AnnotationTypeDoc.class);
+            case "enums":
+              return filter(((PackageDoc) target).enums(),
+                      ClassDoc.class);
+            case "errors":
+              return filter(((PackageDoc) target).errors(),
+                      ClassDoc.class);
+            case "exceptions":
+              return filter(((PackageDoc) target).exceptions(),
+                      ClassDoc.class);
+            case "interfaces":
+              return filter(((PackageDoc) target).interfaces(),
+                      ClassDoc.class);
+            case "ordinaryClasses":
+              return filter(((PackageDoc) target).ordinaryClasses(),
+                      ClassDoc.class);
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/yetus/blob/ad2f57f0/audience-annotations-component/audience-annotations/src/main/java/org/apache/yetus/audience/tools/StabilityOptions.java
----------------------------------------------------------------------
diff --git a/audience-annotations-component/audience-annotations/src/main/java/org/apache/yetus/audience/tools/StabilityOptions.java
b/audience-annotations-component/audience-annotations/src/main/java/org/apache/yetus/audience/tools/StabilityOptions.java
index 854c7b2..8e227c3 100644
--- a/audience-annotations-component/audience-annotations/src/main/java/org/apache/yetus/audience/tools/StabilityOptions.java
+++ b/audience-annotations-component/audience-annotations/src/main/java/org/apache/yetus/audience/tools/StabilityOptions.java
@@ -38,25 +38,29 @@ class StabilityOptions {
 
   public static void validOptions(String[][] options,
       DocErrorReporter reporter) {
-    for (int i = 0; i < options.length; i++) {
-      String opt = options[i][0].toLowerCase(Locale.ENGLISH);
-      if (opt.equals(UNSTABLE_OPTION)) {
-        RootDocProcessor.stability = UNSTABLE_OPTION;
-      } else if (opt.equals(EVOLVING_OPTION)) {
-        RootDocProcessor.stability = EVOLVING_OPTION;
-      } else if (opt.equals(STABLE_OPTION)) {
-        RootDocProcessor.stability = STABLE_OPTION;
+    for (String[] option : options) {
+      String opt = option[0].toLowerCase(Locale.ENGLISH);
+      switch (opt) {
+        case UNSTABLE_OPTION:
+          RootDocProcessor.stability = UNSTABLE_OPTION;
+          break;
+        case EVOLVING_OPTION:
+          RootDocProcessor.stability = EVOLVING_OPTION;
+          break;
+        case STABLE_OPTION:
+          RootDocProcessor.stability = STABLE_OPTION;
+          break;
       }
     }
   }
 
   public static String[][] filterOptions(String[][] options) {
     List<String[]> optionsList = new ArrayList<String[]>(options.length);
-    for (int i = 0; i < options.length; i++) {
-      if (!options[i][0].equalsIgnoreCase(UNSTABLE_OPTION)
-          && !options[i][0].equalsIgnoreCase(EVOLVING_OPTION)
-          && !options[i][0].equalsIgnoreCase(STABLE_OPTION)) {
-        optionsList.add(options[i]);
+    for (String[] option1 : options) {
+      if (!option1[0].equalsIgnoreCase(UNSTABLE_OPTION)
+              && !option1[0].equalsIgnoreCase(EVOLVING_OPTION)
+              && !option1[0].equalsIgnoreCase(STABLE_OPTION)) {
+        optionsList.add(option1);
       }
     }
     String[][] filteredOptions = new String[optionsList.size()][];


Mime
View raw message