{"action":"opened","issue":{"url":"https://api.github.com/repos/Microsoft/thrifty/issues/244","repository_url":"https://api.github.com/repos/Microsoft/thrifty","labels_url":"https://api.github.com/repos/Microsoft/thrifty/issues/244/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/thrifty/issues/244/comments","events_url":"https://api.github.com/repos/Microsoft/thrifty/issues/244/events","html_url":"https://github.com/Microsoft/thrifty/issues/244","id":366082105,"node_id":"MDU6SXNzdWUzNjYwODIxMDU=","number":244,"title":"Constructing Builders with nullable structs","user":{"login":"jparise","id":10311,"node_id":"MDQ6VXNlcjEwMzEx","avatar_url":"https://avatars1.githubusercontent.com/u/10311?v=4","gravatar_id":"","url":"https://api.github.com/users/jparise","html_url":"https://github.com/jparise","followers_url":"https://api.github.com/users/jparise/followers","following_url":"https://api.github.com/users/jparise/following{/other_user}","gists_url":"https://api.github.com/users/jparise/gists{/gist_id}","starred_url":"https://api.github.com/users/jparise/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jparise/subscriptions","organizations_url":"https://api.github.com/users/jparise/orgs","repos_url":"https://api.github.com/users/jparise/repos","events_url":"https://api.github.com/users/jparise/events{/privacy}","received_events_url":"https://api.github.com/users/jparise/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-02T21:12:44Z","updated_at":"2018-10-02T21:12:44Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"As I convert more and more (Java) code from Apache Thrift to Thrifty, I've started to run into a pattern where I start with an existing struct object that _might_ be `null` and then \"extends\" that struct by setting some existing values. The most direct way to do this is by conditionally calling the correct Builder construct:\r\n\r\n```java\r\npublic Struct updateStruct(Struct struct) {\r\n    Struct.Builder builder = (struct == null)\r\n        ? new Struct.Builder()\r\n        : new Struct.Builder(struct);\r\n\r\n    builder.foo(True);\r\n\r\n    return builder.build();\r\n}\r\n```\r\n\r\nIt would be much more convenient if `Struct.Builder` accepted a nullable argument and added a `if (struct != null)` guard to the generated code so the above could just become:\r\n\r\n```java\r\npublic Struct updateStruct(Struct struct) {\r\n    return new Struct.Builder(struct)\r\n        .foo(True)\r\n        .build();\r\n}\r\n```\r\n\r\nThat would detract a bit from the purity of the existing Builder interface, but this could be a case where caller convenience could take precedence."}}
{"actor":{"display_login":"jparise"}}