{"action":"created","comment":{"url":"https://api.github.com/repos/netty/netty/pulls/comments/48080410","id":48080410,"diff_hunk":"@@ -0,0 +1,193 @@\n+/*\n+ * Copyright 2015 The Netty Project\n+ *\n+ * The Netty Project licenses this file to you under the Apache License,\n+ * version 2.0 (the \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at:\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package io.netty.util;\n+\n+import java.util.LinkedHashMap;\n+import java.util.Map;\n+import java.util.Set;\n+\n+import static io.netty.util.internal.ObjectUtil.checkNotNull;\n+\n+/**\n+ * Builder for immutable {@link DomainNameMapping} instances.\n+ *\n+ * @param <V> concrete type of value objects\n+ */\n+public final class DomainMappingBuilder<V> {\n+\n+    private final V defaultValue;\n+    private final Map<String, V> map;\n+\n+    /**\n+     * Constructor with default initial capacity of the map holding the mappings\n+     *\n+     * @param defaultValue the default value for {@link DomainNameMapping#map(String)} to return\n+     *                     when nothing matches the input\n+     */\n+    public DomainMappingBuilder(V defaultValue) {\n+        this(4, defaultValue);\n+    }\n+\n+    /**\n+     * Constructor with initial capacity of the map holding the mappings\n+     *\n+     * @param initialCapacity initial capacity for the internal map\n+     * @param defaultValue    the default value for {@link DomainNameMapping#map(String)} to return\n+     *                        when nothing matches the input\n+     */\n+    public DomainMappingBuilder(int initialCapacity, V defaultValue) {\n+        this.defaultValue = checkNotNull(defaultValue, \"defaultValue\");\n+        this.map = new LinkedHashMap<String, V>(initialCapacity);\n+    }\n+\n+    /**\n+     * Adds a mapping that maps the specified (optionally wildcard) host name to the specified output value.\n+     * Null values are forbidden for both hostnames and values.\n+     * <p>\n+     * <a href=\"http://en.wikipedia.org/wiki/Wildcard_DNS_record\">DNS wildcard</a> is supported as hostname.\n+     * For example, you can use {@code *.netty.io} to match {@code netty.io} and {@code downloads.netty.io}.\n+     * </p>\n+     *\n+     * @param hostname the host name (optionally wildcard)\n+     * @param output   the output value that will be returned by {@link DomainNameMapping#map(String)}\n+     *                 when the specified host name matches the specified input host name\n+     */\n+    public DomainMappingBuilder<V> add(String hostname, V output) {\n+        map.put(","path":"common/src/main/java/io/netty/util/DomainMappingBuilder.java","position":70,"original_position":70,"commit_id":"ac7daa17033b2ea7750e56612dd591a03ed058a5","original_commit_id":"ac7daa17033b2ea7750e56612dd591a03ed058a5","user":{"login":"Scottmitch","id":7562868,"avatar_url":"https://avatars.githubusercontent.com/u/7562868?v=3","gravatar_id":"","url":"https://api.github.com/users/Scottmitch","html_url":"https://github.com/Scottmitch","followers_url":"https://api.github.com/users/Scottmitch/followers","following_url":"https://api.github.com/users/Scottmitch/following{/other_user}","gists_url":"https://api.github.com/users/Scottmitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Scottmitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Scottmitch/subscriptions","organizations_url":"https://api.github.com/users/Scottmitch/orgs","repos_url":"https://api.github.com/users/Scottmitch/repos","events_url":"https://api.github.com/users/Scottmitch/events{/privacy}","received_events_url":"https://api.github.com/users/Scottmitch/received_events","type":"User","site_admin":false},"body":"will this not fit on 1 line?","created_at":"2015-12-18T23:11:59Z","updated_at":"2015-12-18T23:11:59Z","html_url":"https://github.com/netty/netty/pull/4579#discussion_r48080410","pull_request_url":"https://api.github.com/repos/netty/netty/pulls/4579","_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/comments/48080410"},"html":{"href":"https://github.com/netty/netty/pull/4579#discussion_r48080410"},"pull_request":{"href":"https://api.github.com/repos/netty/netty/pulls/4579"}}},"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/4579","id":53906450,"html_url":"https://github.com/netty/netty/pull/4579","diff_url":"https://github.com/netty/netty/pull/4579.diff","patch_url":"https://github.com/netty/netty/pull/4579.patch","issue_url":"https://api.github.com/repos/netty/netty/issues/4579","number":4579,"state":"open","locked":false,"title":"[#4201] Consider using builder pattern to construct DomainNameMapping.","user":{"login":"eantaev","id":466074,"avatar_url":"https://avatars.githubusercontent.com/u/466074?v=3","gravatar_id":"","url":"https://api.github.com/users/eantaev","html_url":"https://github.com/eantaev","followers_url":"https://api.github.com/users/eantaev/followers","following_url":"https://api.github.com/users/eantaev/following{/other_user}","gists_url":"https://api.github.com/users/eantaev/gists{/gist_id}","starred_url":"https://api.github.com/users/eantaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eantaev/subscriptions","organizations_url":"https://api.github.com/users/eantaev/orgs","repos_url":"https://api.github.com/users/eantaev/repos","events_url":"https://api.github.com/users/eantaev/events{/privacy}","received_events_url":"https://api.github.com/users/eantaev/received_events","type":"User","site_admin":false},"body":"Made an immutable implementation of DomainNameMapping;\r\nAdded Builder for immutable DomainNameMapping;\r\nReplaced regex pattern with String::startsWith check;\r\nReplaced HashMap with two arrays in ImmutableDomainNameMapping;\r\nDeprecated mutable API;\r\nUnit tests.","created_at":"2015-12-16T22:13:01Z","updated_at":"2015-12-18T23:11:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8c25193cf1af819b1acea8a99874cf86abd16c8c","assignee":{"login":"trustin","id":173918,"avatar_url":"https://avatars.githubusercontent.com/u/173918?v=3","gravatar_id":"","url":"https://api.github.com/users/trustin","html_url":"https://github.com/trustin","followers_url":"https://api.github.com/users/trustin/followers","following_url":"https://api.github.com/users/trustin/following{/other_user}","gists_url":"https://api.github.com/users/trustin/gists{/gist_id}","starred_url":"https://api.github.com/users/trustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trustin/subscriptions","organizations_url":"https://api.github.com/users/trustin/orgs","repos_url":"https://api.github.com/users/trustin/repos","events_url":"https://api.github.com/users/trustin/events{/privacy}","received_events_url":"https://api.github.com/users/trustin/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/netty/netty/milestones/126","html_url":"https://github.com/netty/netty/milestones/4.1.0.CR1","labels_url":"https://api.github.com/repos/netty/netty/milestones/126/labels","id":1286123,"number":126,"title":"4.1.0.CR1","description":"","creator":{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars.githubusercontent.com/u/439362?v=3","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false},"open_issues":15,"closed_issues":41,"state":"open","created_at":"2015-09-02T12:42:53Z","updated_at":"2015-12-18T22:42:56Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/netty/netty/pulls/4579/commits","review_comments_url":"https://api.github.com/repos/netty/netty/pulls/4579/comments","review_comment_url":"https://api.github.com/repos/netty/netty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netty/netty/issues/4579/comments","statuses_url":"https://api.github.com/repos/netty/netty/statuses/ac7daa17033b2ea7750e56612dd591a03ed058a5","head":{"label":"eantaev:domain-name-mapping-builder","ref":"domain-name-mapping-builder","sha":"ac7daa17033b2ea7750e56612dd591a03ed058a5","user":{"login":"eantaev","id":466074,"avatar_url":"https://avatars.githubusercontent.com/u/466074?v=3","gravatar_id":"","url":"https://api.github.com/users/eantaev","html_url":"https://github.com/eantaev","followers_url":"https://api.github.com/users/eantaev/followers","following_url":"https://api.github.com/users/eantaev/following{/other_user}","gists_url":"https://api.github.com/users/eantaev/gists{/gist_id}","starred_url":"https://api.github.com/users/eantaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eantaev/subscriptions","organizations_url":"https://api.github.com/users/eantaev/orgs","repos_url":"https://api.github.com/users/eantaev/repos","events_url":"https://api.github.com/users/eantaev/events{/privacy}","received_events_url":"https://api.github.com/users/eantaev/received_events","type":"User","site_admin":false},"repo":{"id":48129477,"name":"netty","full_name":"eantaev/netty","owner":{"login":"eantaev","id":466074,"avatar_url":"https://avatars.githubusercontent.com/u/466074?v=3","gravatar_id":"","url":"https://api.github.com/users/eantaev","html_url":"https://github.com/eantaev","followers_url":"https://api.github.com/users/eantaev/followers","following_url":"https://api.github.com/users/eantaev/following{/other_user}","gists_url":"https://api.github.com/users/eantaev/gists{/gist_id}","starred_url":"https://api.github.com/users/eantaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eantaev/subscriptions","organizations_url":"https://api.github.com/users/eantaev/orgs","repos_url":"https://api.github.com/users/eantaev/repos","events_url":"https://api.github.com/users/eantaev/events{/privacy}","received_events_url":"https://api.github.com/users/eantaev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eantaev/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":true,"url":"https://api.github.com/repos/eantaev/netty","forks_url":"https://api.github.com/repos/eantaev/netty/forks","keys_url":"https://api.github.com/repos/eantaev/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eantaev/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eantaev/netty/teams","hooks_url":"https://api.github.com/repos/eantaev/netty/hooks","issue_events_url":"https://api.github.com/repos/eantaev/netty/issues/events{/number}","events_url":"https://api.github.com/repos/eantaev/netty/events","assignees_url":"https://api.github.com/repos/eantaev/netty/assignees{/user}","branches_url":"https://api.github.com/repos/eantaev/netty/branches{/branch}","tags_url":"https://api.github.com/repos/eantaev/netty/tags","blobs_url":"https://api.github.com/repos/eantaev/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eantaev/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eantaev/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/eantaev/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eantaev/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/eantaev/netty/languages","stargazers_url":"https://api.github.com/repos/eantaev/netty/stargazers","contributors_url":"https://api.github.com/repos/eantaev/netty/contributors","subscribers_url":"https://api.github.com/repos/eantaev/netty/subscribers","subscription_url":"https://api.github.com/repos/eantaev/netty/subscription","commits_url":"https://api.github.com/repos/eantaev/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/eantaev/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/eantaev/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/eantaev/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/eantaev/netty/contents/{+path}","compare_url":"https://api.github.com/repos/eantaev/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eantaev/netty/merges","archive_url":"https://api.github.com/repos/eantaev/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eantaev/netty/downloads","issues_url":"https://api.github.com/repos/eantaev/netty/issues{/number}","pulls_url":"https://api.github.com/repos/eantaev/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/eantaev/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/eantaev/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eantaev/netty/labels{/name}","releases_url":"https://api.github.com/repos/eantaev/netty/releases{/id}","created_at":"2015-12-16T19:06:27Z","updated_at":"2015-12-16T19:06:36Z","pushed_at":"2015-12-18T22:18:46Z","git_url":"git://github.com/eantaev/netty.git","ssh_url":"git@github.com:eantaev/netty.git","clone_url":"https://github.com/eantaev/netty.git","svn_url":"https://github.com/eantaev/netty","homepage":"http://netty.io/","size":46129,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"4.1"}},"base":{"label":"netty:4.1","ref":"4.1","sha":"f750d6e36c80e88fb302c99b5b7413e5649e6738","user":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"repo":{"id":1064563,"name":"netty","full_name":"netty/netty","owner":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netty/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":false,"url":"https://api.github.com/repos/netty/netty","forks_url":"https://api.github.com/repos/netty/netty/forks","keys_url":"https://api.github.com/repos/netty/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netty/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netty/netty/teams","hooks_url":"https://api.github.com/repos/netty/netty/hooks","issue_events_url":"https://api.github.com/repos/netty/netty/issues/events{/number}","events_url":"https://api.github.com/repos/netty/netty/events","assignees_url":"https://api.github.com/repos/netty/netty/assignees{/user}","branches_url":"https://api.github.com/repos/netty/netty/branches{/branch}","tags_url":"https://api.github.com/repos/netty/netty/tags","blobs_url":"https://api.github.com/repos/netty/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netty/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netty/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/netty/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netty/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/netty/netty/languages","stargazers_url":"https://api.github.com/repos/netty/netty/stargazers","contributors_url":"https://api.github.com/repos/netty/netty/contributors","subscribers_url":"https://api.github.com/repos/netty/netty/subscribers","subscription_url":"https://api.github.com/repos/netty/netty/subscription","commits_url":"https://api.github.com/repos/netty/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/netty/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/netty/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/netty/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/netty/netty/contents/{+path}","compare_url":"https://api.github.com/repos/netty/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netty/netty/merges","archive_url":"https://api.github.com/repos/netty/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netty/netty/downloads","issues_url":"https://api.github.com/repos/netty/netty/issues{/number}","pulls_url":"https://api.github.com/repos/netty/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/netty/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/netty/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netty/netty/labels{/name}","releases_url":"https://api.github.com/repos/netty/netty/releases{/id}","created_at":"2010-11-09T09:22:21Z","updated_at":"2015-12-18T23:00:16Z","pushed_at":"2015-12-18T22:42:21Z","git_url":"git://github.com/netty/netty.git","ssh_url":"git@github.com:netty/netty.git","clone_url":"https://github.com/netty/netty.git","svn_url":"https://github.com/netty/netty","homepage":"http://netty.io/","size":58002,"stargazers_count":5789,"watchers_count":5789,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2933,"mirror_url":null,"open_issues_count":326,"forks":2933,"open_issues":326,"watchers":5789,"default_branch":"4.1"}},"_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/4579"},"html":{"href":"https://github.com/netty/netty/pull/4579"},"issue":{"href":"https://api.github.com/repos/netty/netty/issues/4579"},"comments":{"href":"https://api.github.com/repos/netty/netty/issues/4579/comments"},"review_comments":{"href":"https://api.github.com/repos/netty/netty/pulls/4579/comments"},"review_comment":{"href":"https://api.github.com/repos/netty/netty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netty/netty/pulls/4579/commits"},"statuses":{"href":"https://api.github.com/repos/netty/netty/statuses/ac7daa17033b2ea7750e56612dd591a03ed058a5"}}}}