{"action":"created","issue":{"url":"https://api.github.com/repos/square/wire/issues/423","labels_url":"https://api.github.com/repos/square/wire/issues/423/labels{/name}","comments_url":"https://api.github.com/repos/square/wire/issues/423/comments","events_url":"https://api.github.com/repos/square/wire/issues/423/events","html_url":"https://github.com/square/wire/issues/423","id":107377939,"number":423,"title":"Null-safe proto adapter instances","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},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/square/wire/milestones/1","html_url":"https://github.com/square/wire/milestones/2.0","labels_url":"https://api.github.com/repos/square/wire/milestones/1/labels","id":536646,"number":1,"title":"2.0","description":"","creator":{"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},"open_issues":3,"closed_issues":5,"state":"open","created_at":"2014-01-15T07:28:18Z","updated_at":"2015-09-20T16:03:12Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2015-09-20T07:35:43Z","updated_at":"2015-09-20T16:03:12Z","closed_at":"2015-09-20T16:03:12Z","body":"Should all `ProtoAdapter` instances ignore `null` values, or should we offer a `nullSafe()` method? This is useful for generated code to avoid having to conditionally call for every field.\r\n\r\nCompare\r\n```java\r\n@Override public int encodedSize(Person value) {\r\n  return (value.name == null ? 0 : nameAdapter.encodedSize(1, value.name))\r\n      + (value.id == null ? 0 : idAdapter.encodedSize(2, value.id))\r\n      + (value.email == null ? 0 : emailAdapter.encodedSize(3, value.email))\r\n      + (value.phone.isEmpty() ? 0 : phoneAdapterRepeated.encodedSize(4, value.phone))\r\n      + value.tagMap().encodedSize();\r\n}\r\n\r\n@Override public void encode(ProtoWriter writer, Person value) throws IOException {\r\n  if (value.name != null) nameAdapter.encodeTagged(writer, 1, value.name);\r\n  if (value.id != null) idAdapter.encodeTagged(writer, 2, value.id);\r\n  if (value.email != null) emailAdapter.encodeTagged(writer, 3, value.email);\r\n  if (!value.phone.isEmpty()) phoneAdapterRepeated.encodeTagged(writer, 4, value.phone);\r\n  value.tagMap().encode(writer);\r\n}\r\n```\r\nto\r\n```java\r\n@Override public int encodedSize(Person value) {\r\n  return nameAdapter.encodedSize(1, value.name)\r\n      + idAdapter.encodedSize(2, value.id)\r\n      + emailAdapter.encodedSize(3, value.email)\r\n      + phoneAdapterRepeated.encodedSize(4, value.phone)\r\n      + value.tagMap().encodedSize();\r\n}\r\n\r\n@Override public void encode(ProtoWriter writer, Person value) throws IOException {\r\n  nameAdapter.encodeTagged(writer, 1, value.name);\r\n  idAdapter.encodeTagged(writer, 2, value.id);\r\n  emailAdapter.encodeTagged(writer, 3, value.email);\r\n  phoneAdapterRepeated.encodeTagged(writer, 4, value.phone);\r\n  value.tagMap().encode(writer);\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/square/wire/issues/comments/141802742","html_url":"https://github.com/square/wire/issues/423#issuecomment-141802742","issue_url":"https://api.github.com/repos/square/wire/issues/423","id":141802742,"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},"created_at":"2015-09-20T16:03:12Z","updated_at":"2015-09-20T16:03:12Z","body":"This gets hairy with repeated fields and the generated code needs to handle nulls in all its methods if we were to do this. Going to leave it as-is."}}