{"action":"created","comment":{"url":"https://api.github.com/repos/mulesoft/mule/pulls/comments/33498164","id":33498164,"diff_hunk":"@@ -0,0 +1,283 @@\n+/*\n+ * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com\n+ * The software in this package is published under the terms of the CPAL v1.0\n+ * license, a copy of which has been included with this distribution in the\n+ * LICENSE.txt file.\n+ */\n+package org.mule.module.extension.internal.util;\n+\n+import org.mule.extension.annotations.Alias;\n+import org.mule.extension.introspection.DataType;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+import org.apache.commons.lang.StringUtils;\n+\n+public class NameUtils\n+{\n+\n+    private static final List<Inflection> plural = new ArrayList<>();\n+    private static final List<Inflection> singular = new ArrayList<>();\n+    private static final List<String> uncountable = new ArrayList<>();\n+\n+    //TODO: Refactor this. This was fine on devkit but we can't keep all these static info in runtime\n+    static\n+    {\n+        // plural is \"singular to plural form\"\n+        // singular is \"plural to singular form\"\n+        plural(\"$\", \"s\");\n+        plural(\"s$\", \"s\");\n+        plural(\"(ax|test)is$\", \"$1es\");\n+        plural(\"(octop|vir)us$\", \"$1i\");\n+        plural(\"(alias|status)$\", \"$1es\");\n+        plural(\"(bu)s$\", \"$1ses\");\n+        plural(\"(buffal|tomat)o$\", \"$1oes\");\n+        plural(\"([ti])um$\", \"$1a\");\n+        plural(\"sis$\", \"ses\");\n+        plural(\"(?:([^f])fe|([lr])f)$\", \"$1$2ves\");\n+        plural(\"(hive)$\", \"$1s\");\n+        plural(\"([^aeiouy]|qu)y$\", \"$1ies\");\n+        //plural(\"([^aeiouy]|qu)ies$\", \"$1y\");\n+        plural(\"(x|ch|ss|sh)$\", \"$1es\");\n+        plural(\"(matr|vert|ind)ix|ex$\", \"$1ices\");\n+        plural(\"([m|l])ouse$\", \"$1ice\");\n+        plural(\"^(ox)$\", \"$1en\");\n+        plural(\"(quiz)$\", \"$1zes\");\n+\n+        singular(\"s$\", \"\");\n+        singular(\"(n)ews$\", \"$1ews\");\n+        singular(\"([ti])a$\", \"$1um\");\n+        singular(\"((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$\", \"$1$2sis\");\n+        singular(\"(^analy)ses$\", \"$1sis\");\n+        singular(\"([^f])ves$\", \"$1fe\");\n+        singular(\"(hive)s$\", \"$1\");\n+        singular(\"(tive)s$\", \"$1\");\n+        singular(\"([lr])ves$\", \"$1f\");\n+        singular(\"([^aeiouy]|qu)ies$\", \"$1y\");\n+        singular(\"(s)eries$\", \"$1eries\");\n+        singular(\"(m)ovies$\", \"$1ovie\");\n+        singular(\"(x|ch|ss|sh)es$\", \"$1\");\n+        singular(\"([m|l])ice$\", \"$1ouse\");\n+        singular(\"(bus)es$\", \"$1\");\n+        singular(\"(o)es$\", \"$1\");\n+        singular(\"(shoe)s$\", \"$1\");\n+        singular(\"(cris|ax|test)es$\", \"$1is\");\n+        singular(\"(octop|vir)i$\", \"$1us\");\n+        singular(\"(alias|status)es$\", \"$1\");\n+        singular(\"^(ox)en\", \"$1\");\n+        singular(\"(vert|ind)ices$\", \"$1ex\");\n+        singular(\"(matr)ices$\", \"$1ix\");\n+        singular(\"(quiz)zes$\", \"$1\");\n+\n+        // irregular\n+        irregular(\"person\", \"people\");\n+        irregular(\"man\", \"men\");\n+        irregular(\"child\", \"children\");\n+        irregular(\"sex\", \"sexes\");\n+        irregular(\"move\", \"moves\");\n+\n+        uncountable(\"equipment\");\n+        uncountable(\"information\");\n+        uncountable(\"rice\");\n+        uncountable(\"money\");\n+        uncountable(\"species\");\n+        uncountable(\"series\");\n+        uncountable(\"fish\");\n+        uncountable(\"sheep\");\n+    }\n+\n+    private static void plural(String pattern, String replacement)\n+    {\n+        plural.add(0, new Inflection(pattern, replacement));\n+    }\n+\n+    private static void singular(String pattern, String replacement)\n+    {\n+        singular.add(0, new Inflection(pattern, replacement));\n+    }\n+\n+    private static void irregular(String s, String p)\n+    {\n+        plural(\"(\" + s.substring(0, 1) + \")\" + s.substring(1) + \"$\", \"$1\" + p.substring(1));\n+        singular(\"(\" + p.substring(0, 1) + \")\" + p.substring(1) + \"$\", \"$1\" + s.substring(1));\n+    }\n+\n+    private static void uncountable(String word)\n+    {\n+        uncountable.add(word);\n+    }\n+\n+    public static String camel(String uncamelCaseName)\n+    {\n+        String result = \"\";\n+        String[] parts = uncamelCaseName.split(\"-\");\n+\n+        for (int i = 0; i < parts.length; i++)\n+        {\n+            result += StringUtils.capitalize(parts[i].toLowerCase());\n+        }\n+\n+        return result;\n+    }\n+\n+    public static String getSetterName(String name)\n+    {\n+        return \"set\" + name.substring(0, 1).toUpperCase() + name.substring(1);\n+    }\n+\n+    public static String hyphenize(String camelCaseName)\n+    {\n+        if (StringUtils.isBlank(camelCaseName))\n+        {\n+            return camelCaseName;\n+        }\n+\n+        String result = \"\";\n+        String[] parts = camelCaseName.split(\"(?<!^)(?=[A-Z])\");\n+\n+        for (int i = 0; i < parts.length; i++)\n+        {\n+            result += parts[i].toLowerCase() + (i < parts.length - 1 ? \"-\" : \"\");\n+        }\n+\n+        return result;\n+    }\n+\n+    /**\n+     * Return the pluralized version of a word.\n+     *\n+     * @param word The word\n+     * @return The pluralized word\n+     */\n+    public static String pluralize(String word)\n+    {\n+        if (isUncountable(word))\n+        {\n+            return word;\n+        }\n+        else\n+        {\n+            for (Inflection inflection : plural)\n+            {\n+                if (inflection.match(word))\n+                {\n+                    return inflection.replace(word);\n+                }\n+            }\n+            return word;\n+        }\n+    }\n+\n+    /**\n+     * Return the singularized version of a word.\n+     *\n+     * @param word The word\n+     * @return The singularized word\n+     */\n+    public static String singularize(String word)\n+    {\n+        if (isUncountable(word))\n+        {\n+            return word;\n+        }\n+        else\n+        {\n+            for (Inflection inflection : singular)\n+            {\n+                if (inflection.match(word))\n+                {\n+                    return inflection.replace(word);\n+                }\n+            }\n+        }\n+        return word;\n+    }\n+\n+    /**\n+     * Return true if the word is uncountable.\n+     *\n+     * @param word The word\n+     * @return True if it is uncountable\n+     */\n+    public static boolean isUncountable(String word)\n+    {\n+        if (StringUtils.isBlank(word))\n+        {\n+            for (String w : uncountable)\n+            {\n+                if (w.equalsIgnoreCase(word))\n+                {\n+                    return true;\n+                }\n+            }\n+        }\n+\n+        return false;\n+    }\n+\n+    public static String getGlobalPojoTypeName(DataType type)","path":"modules/extensions-support/src/main/java/org/mule/module/extension/internal/util/NameUtils.java","position":219,"original_position":219,"commit_id":"b5caf4587308059931df27df8471d78d02e0c776","original_commit_id":"b5caf4587308059931df27df8471d78d02e0c776","user":{"login":"marianogonzalez","id":1272771,"avatar_url":"https://avatars.githubusercontent.com/u/1272771?v=3","gravatar_id":"","url":"https://api.github.com/users/marianogonzalez","html_url":"https://github.com/marianogonzalez","followers_url":"https://api.github.com/users/marianogonzalez/followers","following_url":"https://api.github.com/users/marianogonzalez/following{/other_user}","gists_url":"https://api.github.com/users/marianogonzalez/gists{/gist_id}","starred_url":"https://api.github.com/users/marianogonzalez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marianogonzalez/subscriptions","organizations_url":"https://api.github.com/users/marianogonzalez/orgs","repos_url":"https://api.github.com/users/marianogonzalez/repos","events_url":"https://api.github.com/users/marianogonzalez/events{/privacy}","received_events_url":"https://api.github.com/users/marianogonzalez/received_events","type":"User","site_admin":false},"body":"renamed to getTopLevelTypeName()","created_at":"2015-06-29T18:50:38Z","updated_at":"2015-06-29T18:50:38Z","html_url":"https://github.com/mulesoft/mule/pull/1534#discussion_r33498164","pull_request_url":"https://api.github.com/repos/mulesoft/mule/pulls/1534","_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/comments/33498164"},"html":{"href":"https://github.com/mulesoft/mule/pull/1534#discussion_r33498164"},"pull_request":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/1534"}}},"pull_request":{"url":"https://api.github.com/repos/mulesoft/mule/pulls/1534","id":32337561,"html_url":"https://github.com/mulesoft/mule/pull/1534","diff_url":"https://github.com/mulesoft/mule/pull/1534.diff","patch_url":"https://github.com/mulesoft/mule/pull/1534.patch","issue_url":"https://api.github.com/repos/mulesoft/mule/issues/1534","number":1534,"state":"open","locked":false,"title":"REVIEW EXT-API... DO NOT MERGE!!!!!!!!","user":{"login":"marianogonzalez","id":1272771,"avatar_url":"https://avatars.githubusercontent.com/u/1272771?v=3","gravatar_id":"","url":"https://api.github.com/users/marianogonzalez","html_url":"https://github.com/marianogonzalez","followers_url":"https://api.github.com/users/marianogonzalez/followers","following_url":"https://api.github.com/users/marianogonzalez/following{/other_user}","gists_url":"https://api.github.com/users/marianogonzalez/gists{/gist_id}","starred_url":"https://api.github.com/users/marianogonzalez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marianogonzalez/subscriptions","organizations_url":"https://api.github.com/users/marianogonzalez/orgs","repos_url":"https://api.github.com/users/marianogonzalez/repos","events_url":"https://api.github.com/users/marianogonzalez/events{/privacy}","received_events_url":"https://api.github.com/users/marianogonzalez/received_events","type":"User","site_admin":false},"body":"you merge it -> you buy both pastries AND Ice cream","created_at":"2015-03-31T16:03:28Z","updated_at":"2015-06-29T18:50:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"efecf521af883136d11b86120aedd6eb75001016","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mulesoft/mule/pulls/1534/commits","review_comments_url":"https://api.github.com/repos/mulesoft/mule/pulls/1534/comments","review_comment_url":"https://api.github.com/repos/mulesoft/mule/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mulesoft/mule/issues/1534/comments","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/b5caf4587308059931df27df8471d78d02e0c776","head":{"label":"mulesoft:ext-api-review","ref":"ext-api-review","sha":"b5caf4587308059931df27df8471d78d02e0c776","user":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"repo":{"id":7058562,"name":"mule","full_name":"mulesoft/mule","owner":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mulesoft/mule","description":"Mule Community Edition","fork":false,"url":"https://api.github.com/repos/mulesoft/mule","forks_url":"https://api.github.com/repos/mulesoft/mule/forks","keys_url":"https://api.github.com/repos/mulesoft/mule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mulesoft/mule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mulesoft/mule/teams","hooks_url":"https://api.github.com/repos/mulesoft/mule/hooks","issue_events_url":"https://api.github.com/repos/mulesoft/mule/issues/events{/number}","events_url":"https://api.github.com/repos/mulesoft/mule/events","assignees_url":"https://api.github.com/repos/mulesoft/mule/assignees{/user}","branches_url":"https://api.github.com/repos/mulesoft/mule/branches{/branch}","tags_url":"https://api.github.com/repos/mulesoft/mule/tags","blobs_url":"https://api.github.com/repos/mulesoft/mule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mulesoft/mule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mulesoft/mule/git/refs{/sha}","trees_url":"https://api.github.com/repos/mulesoft/mule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/{sha}","languages_url":"https://api.github.com/repos/mulesoft/mule/languages","stargazers_url":"https://api.github.com/repos/mulesoft/mule/stargazers","contributors_url":"https://api.github.com/repos/mulesoft/mule/contributors","subscribers_url":"https://api.github.com/repos/mulesoft/mule/subscribers","subscription_url":"https://api.github.com/repos/mulesoft/mule/subscription","commits_url":"https://api.github.com/repos/mulesoft/mule/commits{/sha}","git_commits_url":"https://api.github.com/repos/mulesoft/mule/git/commits{/sha}","comments_url":"https://api.github.com/repos/mulesoft/mule/comments{/number}","issue_comment_url":"https://api.github.com/repos/mulesoft/mule/issues/comments{/number}","contents_url":"https://api.github.com/repos/mulesoft/mule/contents/{+path}","compare_url":"https://api.github.com/repos/mulesoft/mule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mulesoft/mule/merges","archive_url":"https://api.github.com/repos/mulesoft/mule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mulesoft/mule/downloads","issues_url":"https://api.github.com/repos/mulesoft/mule/issues{/number}","pulls_url":"https://api.github.com/repos/mulesoft/mule/pulls{/number}","milestones_url":"https://api.github.com/repos/mulesoft/mule/milestones{/number}","notifications_url":"https://api.github.com/repos/mulesoft/mule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mulesoft/mule/labels{/name}","releases_url":"https://api.github.com/repos/mulesoft/mule/releases{/id}","created_at":"2012-12-07T19:23:06Z","updated_at":"2015-06-27T17:56:59Z","pushed_at":"2015-06-29T18:49:12Z","git_url":"git://github.com/mulesoft/mule.git","ssh_url":"git@github.com:mulesoft/mule.git","clone_url":"https://github.com/mulesoft/mule.git","svn_url":"https://github.com/mulesoft/mule","homepage":null,"size":460357,"stargazers_count":210,"watchers_count":210,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":264,"mirror_url":null,"open_issues_count":15,"forks":264,"open_issues":15,"watchers":210,"default_branch":"mule-3.x"}},"base":{"label":"mulesoft:mule-3.6.x","ref":"mule-3.6.x","sha":"256214089d1240cb837bb2b23343dc89f1a168ef","user":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"repo":{"id":7058562,"name":"mule","full_name":"mulesoft/mule","owner":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mulesoft/mule","description":"Mule Community Edition","fork":false,"url":"https://api.github.com/repos/mulesoft/mule","forks_url":"https://api.github.com/repos/mulesoft/mule/forks","keys_url":"https://api.github.com/repos/mulesoft/mule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mulesoft/mule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mulesoft/mule/teams","hooks_url":"https://api.github.com/repos/mulesoft/mule/hooks","issue_events_url":"https://api.github.com/repos/mulesoft/mule/issues/events{/number}","events_url":"https://api.github.com/repos/mulesoft/mule/events","assignees_url":"https://api.github.com/repos/mulesoft/mule/assignees{/user}","branches_url":"https://api.github.com/repos/mulesoft/mule/branches{/branch}","tags_url":"https://api.github.com/repos/mulesoft/mule/tags","blobs_url":"https://api.github.com/repos/mulesoft/mule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mulesoft/mule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mulesoft/mule/git/refs{/sha}","trees_url":"https://api.github.com/repos/mulesoft/mule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/{sha}","languages_url":"https://api.github.com/repos/mulesoft/mule/languages","stargazers_url":"https://api.github.com/repos/mulesoft/mule/stargazers","contributors_url":"https://api.github.com/repos/mulesoft/mule/contributors","subscribers_url":"https://api.github.com/repos/mulesoft/mule/subscribers","subscription_url":"https://api.github.com/repos/mulesoft/mule/subscription","commits_url":"https://api.github.com/repos/mulesoft/mule/commits{/sha}","git_commits_url":"https://api.github.com/repos/mulesoft/mule/git/commits{/sha}","comments_url":"https://api.github.com/repos/mulesoft/mule/comments{/number}","issue_comment_url":"https://api.github.com/repos/mulesoft/mule/issues/comments{/number}","contents_url":"https://api.github.com/repos/mulesoft/mule/contents/{+path}","compare_url":"https://api.github.com/repos/mulesoft/mule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mulesoft/mule/merges","archive_url":"https://api.github.com/repos/mulesoft/mule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mulesoft/mule/downloads","issues_url":"https://api.github.com/repos/mulesoft/mule/issues{/number}","pulls_url":"https://api.github.com/repos/mulesoft/mule/pulls{/number}","milestones_url":"https://api.github.com/repos/mulesoft/mule/milestones{/number}","notifications_url":"https://api.github.com/repos/mulesoft/mule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mulesoft/mule/labels{/name}","releases_url":"https://api.github.com/repos/mulesoft/mule/releases{/id}","created_at":"2012-12-07T19:23:06Z","updated_at":"2015-06-27T17:56:59Z","pushed_at":"2015-06-29T18:49:12Z","git_url":"git://github.com/mulesoft/mule.git","ssh_url":"git@github.com:mulesoft/mule.git","clone_url":"https://github.com/mulesoft/mule.git","svn_url":"https://github.com/mulesoft/mule","homepage":null,"size":460357,"stargazers_count":210,"watchers_count":210,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":264,"mirror_url":null,"open_issues_count":15,"forks":264,"open_issues":15,"watchers":210,"default_branch":"mule-3.x"}},"_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/1534"},"html":{"href":"https://github.com/mulesoft/mule/pull/1534"},"issue":{"href":"https://api.github.com/repos/mulesoft/mule/issues/1534"},"comments":{"href":"https://api.github.com/repos/mulesoft/mule/issues/1534/comments"},"review_comments":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/1534/comments"},"review_comment":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/1534/commits"},"statuses":{"href":"https://api.github.com/repos/mulesoft/mule/statuses/b5caf4587308059931df27df8471d78d02e0c776"}}}}