]> granicus.if.org Git - icu/commitdiff
ICU-10905 Added a support for Enum methods, based on Markus's feedback.
authorYoshito Umaoka <y.umaoka@gmail.com>
Tue, 10 Jun 2014 15:14:49 +0000 (15:14 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Tue, 10 Jun 2014 15:14:49 +0000 (15:14 +0000)
X-SVN-Rev: 35846

icu4j/tools/build/src/com/ibm/icu/dev/tool/docs/DeprecatedAPIChecker.java

index 567fedbd8b58ecef478d4f3c8b3b8817f98b4f2f..ec83b0625bf7c7c0d96458434ba0427c3519829e 100644 (file)
@@ -203,6 +203,29 @@ public class DeprecatedAPIChecker {
             compareDeprecated(isAPIDeprecated(api), ec.isAnnotationPresent(Deprecated.class), enumName, ecName,\r
                     "Enum Constant");\r
         }\r
+\r
+        // check methods\r
+        for (Method mtd : cls.getDeclaredMethods()) {\r
+            // Note: We exclude built-in methods in a Java Enum instance\r
+            if (!isPublicOrProtected(mtd.getModifiers()) || isBuiltinEnumMethod(mtd)) {\r
+                continue;\r
+            }\r
+\r
+            String mtdName = mtd.getName();\r
+            List<String> paramNames = getParamNames(mtd);\r
+            api = findMethodInfo(apiInfoSet, enumName, mtdName, paramNames);\r
+\r
+            if (api == null) {\r
+                pw.println("## Error ## Method " + enumName + "#" + mtdName + formatParams(paramNames)\r
+                        + " is not found in the API signature data.");\r
+                errCount++;\r
+                continue;\r
+            }\r
+\r
+            compareDeprecated(isAPIDeprecated(api), mtd.isAnnotationPresent(Deprecated.class), enumName, mtdName\r
+                    + formatParams(paramNames), "Method");\r
+\r
+        }\r
     }\r
 \r
     private void compareDeprecated(boolean depTag, boolean depAnt, String cls, String name, String type) {\r
@@ -224,6 +247,13 @@ public class DeprecatedAPIChecker {
         return ((modifier & Modifier.PUBLIC) != 0) || ((modifier & Modifier.PROTECTED) != 0);\r
     }\r
 \r
+    // Check if a method is automatically generated for a each Enum\r
+    private static boolean isBuiltinEnumMethod(Method mtd) {\r
+        // Just check method name for now\r
+        String name = mtd.getName();\r
+        return name.equals("values") || name.equals("valueOf");\r
+    }\r
+\r
     private static boolean isAPIDeprecated(APIInfo api) {\r
         return api.isDeprecated() || api.isInternal() || api.isObsolete();\r
     }\r