{"action":"created","comment":{"url":"https://api.github.com/repos/square/wire/pulls/comments/34325902","id":34325902,"diff_hunk":"@@ -0,0 +1,210 @@\n+/*\n+ * Copyright (C) 2015 Square, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * 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,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package com.squareup.wire;\n+\n+import com.google.common.base.Joiner;\n+import com.google.common.collect.ImmutableList;\n+import com.google.common.collect.ImmutableMap;\n+import com.squareup.protoparser.EnumConstantElement;\n+import com.squareup.protoparser.EnumElement;\n+import com.squareup.protoparser.FieldElement;\n+import com.squareup.protoparser.MessageElement;\n+import com.squareup.protoparser.OneOfElement;\n+import com.squareup.protoparser.TypeElement;\n+import com.squareup.wire.internal.Util;\n+import java.util.Objects;\n+import java.util.Set;\n+\n+import static com.google.common.base.Preconditions.checkNotNull;\n+import static com.google.common.base.Preconditions.checkState;\n+\n+public abstract class Type {\n+  public abstract Name name();\n+  public abstract String documentation();\n+  public abstract Options options();\n+  public abstract ImmutableList<Type> nestedTypes();\n+  abstract void link(Linker linker);\n+  abstract void linkOptions(Linker linker);\n+  abstract Type retainAll(Set<String> identifiers);\n+\n+  static Type get(Name name, TypeElement type) {\n+    if (type instanceof EnumElement) {\n+      EnumElement enumElement = (EnumElement) type;\n+\n+      ImmutableList.Builder<EnumConstant> constants = ImmutableList.builder();\n+      for (EnumConstantElement constant : enumElement.constants()) {\n+        constants.add(new EnumConstant(name.packageName(), constant));\n+      }\n+\n+      Options options = new Options(\n+          Name.ENUM_OPTIONS, name.packageName(), enumElement.options());\n+\n+      return new EnumType(name, enumElement, constants.build(), options);\n+\n+    } else if (type instanceof MessageElement) {\n+      MessageElement messageElement = (MessageElement) type;\n+      String packageName = name.packageName();\n+\n+      ImmutableList.Builder<Field> fields = ImmutableList.builder();\n+      for (FieldElement field : messageElement.fields()) {\n+        fields.add(new Field(packageName, field));\n+      }\n+\n+      ImmutableList.Builder<OneOf> oneOfs = ImmutableList.builder();\n+      for (OneOfElement oneOf : messageElement.oneOfs()) {\n+        oneOfs.add(new OneOf(packageName, oneOf));\n+      }\n+\n+      ImmutableList.Builder<Type> nestedTypes = ImmutableList.builder();\n+      for (TypeElement nestedType : messageElement.nestedElements()) {\n+        nestedTypes.add(Type.get(name.nestedType(nestedType.name()), nestedType));\n+      }\n+\n+      Options options = new Options(\n+          Name.MESSAGE_OPTIONS, name.packageName(), messageElement.options());\n+\n+      return new MessageType(name, messageElement, fields.build(), oneOfs.build(),\n+          nestedTypes.build(), options);\n+\n+    } else {\n+      throw new IllegalArgumentException(\"unexpected type: \" + type.getClass());\n+    }\n+  }\n+\n+  /**\n+   * Names a protocol buffer message, enumerated type, service or a scalar. This class models a\n+   * fully-qualified name using the protocol buffer package.\n+   */\n+  public static final class Name {\n+    public static final Name BOOL = new Name(\"bool\");\n+    public static final Name BYTES = new Name(\"bytes\");\n+    public static final Name DOUBLE = new Name(\"double\");\n+    public static final Name FLOAT = new Name(\"float\");\n+    public static final Name FIXED32 = new Name(\"fixed32\");\n+    public static final Name FIXED64 = new Name(\"fixed64\");\n+    public static final Name INT32 = new Name(\"int32\");\n+    public static final Name INT64 = new Name(\"int64\");\n+    public static final Name SFIXED32 = new Name(\"sfixed32\");\n+    public static final Name SFIXED64 = new Name(\"sfixed64\");\n+    public static final Name SINT32 = new Name(\"sint32\");\n+    public static final Name SINT64 = new Name(\"sint64\");\n+    public static final Name STRING = new Name(\"string\");\n+    public static final Name UINT32 = new Name(\"uint32\");\n+    public static final Name UINT64 = new Name(\"uint64\");\n+\n+    static final Name FILE_OPTIONS = get(\"google.protobuf\", \"FileOptions\");\n+    static final Name MESSAGE_OPTIONS = get(\"google.protobuf\", \"MessageOptions\");\n+    static final Name FIELD_OPTIONS = get(\"google.protobuf\", \"FieldOptions\");\n+    static final Name ENUM_OPTIONS = get(\"google.protobuf\", \"EnumOptions\");\n+    static final Name ENUM_VALUE_OPTIONS = get(\"google.protobuf\", \"EnumValueOptions\");\n+    static final Name SERVICE_OPTIONS = get(\"google.protobuf\", \"ServiceOptions\");\n+    static final Name METHOD_OPTIONS = get(\"google.protobuf\", \"MethodOptions\");\n+\n+    private static final ImmutableMap<String, Name> SCALAR_TYPES;\n+    static {\n+      ImmutableMap.Builder<String, Name> scalarTypes = ImmutableMap.builder();\n+      try {\n+        for (java.lang.reflect.Field field : Name.class.getDeclaredFields()) {\n+          if (field.getType() == Name.class) {\n+            Name name = (Name) field.get(null);\n+            if (name.isScalar) {\n+              scalarTypes.put(name.names.get(0), name);\n+            }\n+          }\n+        }\n+        SCALAR_TYPES = scalarTypes.build();\n+      } catch (IllegalAccessException e) {\n+        throw new AssertionError();\n+      }\n+    }","path":"wire-compiler/src/main/java/com/squareup/wire/Type.java","position":132,"original_position":132,"commit_id":"4d480895e56e4a073d68a68a5778699aca4cafc8","original_commit_id":"4d480895e56e4a073d68a68a5778699aca4cafc8","user":{"login":"swankjesse","id":133019,"avatar_url":"https://avatars.githubusercontent.com/u/133019?v=3","gravatar_id":"","url":"https://api.github.com/users/swankjesse","html_url":"https://github.com/swankjesse","followers_url":"https://api.github.com/users/swankjesse/followers","following_url":"https://api.github.com/users/swankjesse/following{/other_user}","gists_url":"https://api.github.com/users/swankjesse/gists{/gist_id}","starred_url":"https://api.github.com/users/swankjesse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swankjesse/subscriptions","organizations_url":"https://api.github.com/users/swankjesse/orgs","repos_url":"https://api.github.com/users/swankjesse/repos","events_url":"https://api.github.com/users/swankjesse/events{/privacy}","received_events_url":"https://api.github.com/users/swankjesse/received_events","type":"User","site_admin":false},"body":"Good call. Can fix.","created_at":"2015-07-10T03:46:10Z","updated_at":"2015-07-10T03:46:10Z","html_url":"https://github.com/square/wire/pull/255#discussion_r34325902","pull_request_url":"https://api.github.com/repos/square/wire/pulls/255","_links":{"self":{"href":"https://api.github.com/repos/square/wire/pulls/comments/34325902"},"html":{"href":"https://github.com/square/wire/pull/255#discussion_r34325902"},"pull_request":{"href":"https://api.github.com/repos/square/wire/pulls/255"}}},"pull_request":{"url":"https://api.github.com/repos/square/wire/pulls/255","id":39640123,"html_url":"https://github.com/square/wire/pull/255","diff_url":"https://github.com/square/wire/pull/255.diff","patch_url":"https://github.com/square/wire/pull/255.patch","issue_url":"https://api.github.com/repos/square/wire/issues/255","number":255,"state":"closed","locked":false,"title":"Drop the Wire prefix where it's not essential.","user":{"login":"swankjesse","id":133019,"avatar_url":"https://avatars.githubusercontent.com/u/133019?v=3","gravatar_id":"","url":"https://api.github.com/users/swankjesse","html_url":"https://github.com/swankjesse","followers_url":"https://api.github.com/users/swankjesse/followers","following_url":"https://api.github.com/users/swankjesse/following{/other_user}","gists_url":"https://api.github.com/users/swankjesse/gists{/gist_id}","starred_url":"https://api.github.com/users/swankjesse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swankjesse/subscriptions","organizations_url":"https://api.github.com/users/swankjesse/orgs","repos_url":"https://api.github.com/users/swankjesse/repos","events_url":"https://api.github.com/users/swankjesse/events{/privacy}","received_events_url":"https://api.github.com/users/swankjesse/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-09T23:44:18Z","updated_at":"2015-07-10T03:46:10Z","closed_at":"2015-07-10T02:19:03Z","merged_at":"2015-07-10T02:19:03Z","merge_commit_sha":"d5762eda38c60392f846a7d8570e7a6bc64a6671","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/wire/pulls/255/commits","review_comments_url":"https://api.github.com/repos/square/wire/pulls/255/comments","review_comment_url":"https://api.github.com/repos/square/wire/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/wire/issues/255/comments","statuses_url":"https://api.github.com/repos/square/wire/statuses/4d480895e56e4a073d68a68a5778699aca4cafc8","head":{"label":"square:jwilson_0709_unwire","ref":"jwilson_0709_unwire","sha":"4d480895e56e4a073d68a68a5778699aca4cafc8","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":12274147,"name":"wire","full_name":"square/wire","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/wire","description":"Clean, lightweight protocol buffers for Android and Java.","fork":false,"url":"https://api.github.com/repos/square/wire","forks_url":"https://api.github.com/repos/square/wire/forks","keys_url":"https://api.github.com/repos/square/wire/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/wire/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/wire/teams","hooks_url":"https://api.github.com/repos/square/wire/hooks","issue_events_url":"https://api.github.com/repos/square/wire/issues/events{/number}","events_url":"https://api.github.com/repos/square/wire/events","assignees_url":"https://api.github.com/repos/square/wire/assignees{/user}","branches_url":"https://api.github.com/repos/square/wire/branches{/branch}","tags_url":"https://api.github.com/repos/square/wire/tags","blobs_url":"https://api.github.com/repos/square/wire/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/wire/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/wire/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/wire/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/wire/statuses/{sha}","languages_url":"https://api.github.com/repos/square/wire/languages","stargazers_url":"https://api.github.com/repos/square/wire/stargazers","contributors_url":"https://api.github.com/repos/square/wire/contributors","subscribers_url":"https://api.github.com/repos/square/wire/subscribers","subscription_url":"https://api.github.com/repos/square/wire/subscription","commits_url":"https://api.github.com/repos/square/wire/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/wire/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/wire/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/wire/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/wire/contents/{+path}","compare_url":"https://api.github.com/repos/square/wire/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/wire/merges","archive_url":"https://api.github.com/repos/square/wire/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/wire/downloads","issues_url":"https://api.github.com/repos/square/wire/issues{/number}","pulls_url":"https://api.github.com/repos/square/wire/pulls{/number}","milestones_url":"https://api.github.com/repos/square/wire/milestones{/number}","notifications_url":"https://api.github.com/repos/square/wire/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/wire/labels{/name}","releases_url":"https://api.github.com/repos/square/wire/releases{/id}","created_at":"2013-08-21T15:45:47Z","updated_at":"2015-07-09T10:42:40Z","pushed_at":"2015-07-10T02:19:04Z","git_url":"git://github.com/square/wire.git","ssh_url":"git@github.com:square/wire.git","clone_url":"https://github.com/square/wire.git","svn_url":"https://github.com/square/wire","homepage":"","size":4923,"stargazers_count":799,"watchers_count":799,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":128,"mirror_url":null,"open_issues_count":21,"forks":128,"open_issues":21,"watchers":799,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"a3934776016fce3cbbae8c9786256b8f3ed73c15","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":12274147,"name":"wire","full_name":"square/wire","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/wire","description":"Clean, lightweight protocol buffers for Android and Java.","fork":false,"url":"https://api.github.com/repos/square/wire","forks_url":"https://api.github.com/repos/square/wire/forks","keys_url":"https://api.github.com/repos/square/wire/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/wire/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/wire/teams","hooks_url":"https://api.github.com/repos/square/wire/hooks","issue_events_url":"https://api.github.com/repos/square/wire/issues/events{/number}","events_url":"https://api.github.com/repos/square/wire/events","assignees_url":"https://api.github.com/repos/square/wire/assignees{/user}","branches_url":"https://api.github.com/repos/square/wire/branches{/branch}","tags_url":"https://api.github.com/repos/square/wire/tags","blobs_url":"https://api.github.com/repos/square/wire/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/wire/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/wire/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/wire/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/wire/statuses/{sha}","languages_url":"https://api.github.com/repos/square/wire/languages","stargazers_url":"https://api.github.com/repos/square/wire/stargazers","contributors_url":"https://api.github.com/repos/square/wire/contributors","subscribers_url":"https://api.github.com/repos/square/wire/subscribers","subscription_url":"https://api.github.com/repos/square/wire/subscription","commits_url":"https://api.github.com/repos/square/wire/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/wire/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/wire/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/wire/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/wire/contents/{+path}","compare_url":"https://api.github.com/repos/square/wire/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/wire/merges","archive_url":"https://api.github.com/repos/square/wire/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/wire/downloads","issues_url":"https://api.github.com/repos/square/wire/issues{/number}","pulls_url":"https://api.github.com/repos/square/wire/pulls{/number}","milestones_url":"https://api.github.com/repos/square/wire/milestones{/number}","notifications_url":"https://api.github.com/repos/square/wire/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/wire/labels{/name}","releases_url":"https://api.github.com/repos/square/wire/releases{/id}","created_at":"2013-08-21T15:45:47Z","updated_at":"2015-07-09T10:42:40Z","pushed_at":"2015-07-10T02:19:04Z","git_url":"git://github.com/square/wire.git","ssh_url":"git@github.com:square/wire.git","clone_url":"https://github.com/square/wire.git","svn_url":"https://github.com/square/wire","homepage":"","size":4923,"stargazers_count":799,"watchers_count":799,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":128,"mirror_url":null,"open_issues_count":21,"forks":128,"open_issues":21,"watchers":799,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/wire/pulls/255"},"html":{"href":"https://github.com/square/wire/pull/255"},"issue":{"href":"https://api.github.com/repos/square/wire/issues/255"},"comments":{"href":"https://api.github.com/repos/square/wire/issues/255/comments"},"review_comments":{"href":"https://api.github.com/repos/square/wire/pulls/255/comments"},"review_comment":{"href":"https://api.github.com/repos/square/wire/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/wire/pulls/255/commits"},"statuses":{"href":"https://api.github.com/repos/square/wire/statuses/4d480895e56e4a073d68a68a5778699aca4cafc8"}}}}