{"action":"created","comment":{"url":"https://api.github.com/repos/square/wire/pulls/comments/36235134","id":36235134,"diff_hunk":"@@ -0,0 +1,319 @@\n+/*\n+ * Copyright 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 java.io.IOException;\n+import okio.ByteString;\n+\n+import static java.lang.Double.doubleToLongBits;\n+import static java.lang.Float.floatToIntBits;\n+\n+public abstract class TypeAdapter<E> {\n+  static final int FIXED_BOOL_SIZE = 1;\n+  static final int FIXED_32_SIZE = 4;\n+  static final int FIXED_64_SIZE = 8;\n+\n+  final WireType type;\n+\n+  protected TypeAdapter(WireType type) {\n+    this.type = type;\n+  }\n+\n+  /** The serialized size of non-null {@code value}. */\n+  public abstract int serializedSize(E value);\n+\n+  /** Write non-null {@code value} to {@code writer}. */\n+  public abstract void write(E value, ProtoWriter writer) throws IOException;\n+\n+  /** Read a non-null value from {@code reader}. */\n+  public abstract E read(ProtoReader reader) throws IOException;\n+\n+\n+  public static final TypeAdapter<Boolean> BOOL = new TypeAdapter<Boolean>(WireType.VARINT) {\n+    @Override public int serializedSize(Boolean value) {\n+      return FIXED_BOOL_SIZE;\n+    }\n+\n+    @Override public void write(Boolean value, ProtoWriter writer) throws IOException {\n+      writer.writeByte(value ? 1 : 0);\n+    }\n+\n+    @Override public Boolean read(ProtoReader reader) throws IOException {\n+      int value = reader.readByte();\n+      if (value == 0) return Boolean.FALSE;\n+      if (value == 1) return Boolean.TRUE;\n+      throw new IllegalStateException(String.format(\"Invalid boolean value 0x%02x\", value));","path":"wire-runtime/src/main/java/com/squareup/wire/TypeAdapter.java","position":58,"original_position":58,"commit_id":"f3a29ae86f5eb93424f48c6f7a5ac1ccfc04bf7f","original_commit_id":"f3a29ae86f5eb93424f48c6f7a5ac1ccfc04bf7f","user":{"login":"JakeWharton","id":66577,"avatar_url":"https://avatars.githubusercontent.com/u/66577?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeWharton","html_url":"https://github.com/JakeWharton","followers_url":"https://api.github.com/users/JakeWharton/followers","following_url":"https://api.github.com/users/JakeWharton/following{/other_user}","gists_url":"https://api.github.com/users/JakeWharton/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeWharton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeWharton/subscriptions","organizations_url":"https://api.github.com/users/JakeWharton/orgs","repos_url":"https://api.github.com/users/JakeWharton/repos","events_url":"https://api.github.com/users/JakeWharton/events{/privacy}","received_events_url":"https://api.github.com/users/JakeWharton/received_events","type":"User","site_admin":false},"body":"Should be IOException","created_at":"2015-08-04T20:10:23Z","updated_at":"2015-08-04T20:10:23Z","html_url":"https://github.com/square/wire/pull/297#discussion_r36235134","pull_request_url":"https://api.github.com/repos/square/wire/pulls/297","_links":{"self":{"href":"https://api.github.com/repos/square/wire/pulls/comments/36235134"},"html":{"href":"https://github.com/square/wire/pull/297#discussion_r36235134"},"pull_request":{"href":"https://api.github.com/repos/square/wire/pulls/297"}}},"pull_request":{"url":"https://api.github.com/repos/square/wire/pulls/297","id":41611631,"html_url":"https://github.com/square/wire/pull/297","diff_url":"https://github.com/square/wire/pull/297.diff","patch_url":"https://github.com/square/wire/pull/297.patch","issue_url":"https://api.github.com/repos/square/wire/issues/297","number":297,"state":"open","locked":false,"title":"Expose ProtoReader/Writer and add type-safe TypeAdapter.","user":{"login":"JakeWharton","id":66577,"avatar_url":"https://avatars.githubusercontent.com/u/66577?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeWharton","html_url":"https://github.com/JakeWharton","followers_url":"https://api.github.com/users/JakeWharton/followers","following_url":"https://api.github.com/users/JakeWharton/following{/other_user}","gists_url":"https://api.github.com/users/JakeWharton/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeWharton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeWharton/subscriptions","organizations_url":"https://api.github.com/users/JakeWharton/orgs","repos_url":"https://api.github.com/users/JakeWharton/repos","events_url":"https://api.github.com/users/JakeWharton/events{/privacy}","received_events_url":"https://api.github.com/users/JakeWharton/received_events","type":"User","site_admin":false},"body":"This allows partial dynamic reading and writing of single-value types (including messages). Reading and writing enums and repeated/packed values are currently not supported, but will be soon.","created_at":"2015-08-04T20:09:00Z","updated_at":"2015-08-04T20:10:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6fe024d16f2155843125e5ae7a752f34acf64948","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/wire/pulls/297/commits","review_comments_url":"https://api.github.com/repos/square/wire/pulls/297/comments","review_comment_url":"https://api.github.com/repos/square/wire/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/wire/issues/297/comments","statuses_url":"https://api.github.com/repos/square/wire/statuses/f3a29ae86f5eb93424f48c6f7a5ac1ccfc04bf7f","head":{"label":"square:jw/first-public-api","ref":"jw/first-public-api","sha":"f3a29ae86f5eb93424f48c6f7a5ac1ccfc04bf7f","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-08-04T05:45:34Z","pushed_at":"2015-08-04T20:09:01Z","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":6486,"stargazers_count":843,"watchers_count":843,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":132,"mirror_url":null,"open_issues_count":29,"forks":132,"open_issues":29,"watchers":843,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"2766ccc6b1095b8057710be07e75ea9b9b98cd05","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-08-04T05:45:34Z","pushed_at":"2015-08-04T20:09:01Z","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":6486,"stargazers_count":843,"watchers_count":843,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":132,"mirror_url":null,"open_issues_count":29,"forks":132,"open_issues":29,"watchers":843,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/wire/pulls/297"},"html":{"href":"https://github.com/square/wire/pull/297"},"issue":{"href":"https://api.github.com/repos/square/wire/issues/297"},"comments":{"href":"https://api.github.com/repos/square/wire/issues/297/comments"},"review_comments":{"href":"https://api.github.com/repos/square/wire/pulls/297/comments"},"review_comment":{"href":"https://api.github.com/repos/square/wire/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/wire/pulls/297/commits"},"statuses":{"href":"https://api.github.com/repos/square/wire/statuses/f3a29ae86f5eb93424f48c6f7a5ac1ccfc04bf7f"}}}}