{"action":"created","issue":{"url":"https://api.github.com/repos/rzwitserloot/lombok/issues/1230","repository_url":"https://api.github.com/repos/rzwitserloot/lombok","labels_url":"https://api.github.com/repos/rzwitserloot/lombok/issues/1230/labels{/name}","comments_url":"https://api.github.com/repos/rzwitserloot/lombok/issues/1230/comments","events_url":"https://api.github.com/repos/rzwitserloot/lombok/issues/1230/events","html_url":"https://github.com/rzwitserloot/lombok/issues/1230","id":188682715,"number":1230,"title":"@Tolerate not working for @Builder methods?","user":{"login":"nakagawa-atsushi","id":16129867,"avatar_url":"https://avatars.githubusercontent.com/u/16129867?v=3","gravatar_id":"","url":"https://api.github.com/users/nakagawa-atsushi","html_url":"https://github.com/nakagawa-atsushi","followers_url":"https://api.github.com/users/nakagawa-atsushi/followers","following_url":"https://api.github.com/users/nakagawa-atsushi/following{/other_user}","gists_url":"https://api.github.com/users/nakagawa-atsushi/gists{/gist_id}","starred_url":"https://api.github.com/users/nakagawa-atsushi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nakagawa-atsushi/subscriptions","organizations_url":"https://api.github.com/users/nakagawa-atsushi/orgs","repos_url":"https://api.github.com/users/nakagawa-atsushi/repos","events_url":"https://api.github.com/users/nakagawa-atsushi/events{/privacy}","received_events_url":"https://api.github.com/users/nakagawa-atsushi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-11T04:29:10Z","updated_at":"2016-11-14T01:41:35Z","closed_at":null,"body":"**Using lombok version:** 1.16.10\r\n**IDE:** Eclipse Neon.1a Release (4.6.1)\r\n\r\nAccording to [this StackOverflow answer](http://stackoverflow.com/a/33998171/1036728), `@Tolerate` supposedly prevents lombok from not generating a method due to signature conflicts.  `@Tolerate` however does not seem to prevent this with `@Builder`'s field methods:\r\n\r\n### Example of `@Tolerate` not working:\r\n```java\r\n@lombok.Builder\r\npublic class Foo {\r\n\tprivate final int value;\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tFoo.builder().valueAsString(\"42\").build();\r\n\t}\r\n\r\n\tpublic static class FooBuilder {\r\n\t\t@Tolerate\r\n\t\tpublic FooBuilder value(String s) {\r\n\t\t\treturn this.value(Integer.parseInt(s));\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n```\r\nException in thread \"main\" java.lang.Error: Unresolved compilation problem: \r\n\tThe method value(String) in the type Foo.FooBuilder is not applicable for the arguments (int)\r\n\r\n\tat Foo$FooBuilder.value(Foo.java:19)\r\n\tat Foo.main(Foo.java:12)\r\n```\r\n\r\n### Working alternative 1:\r\n\r\n```java\r\n@lombok.Builder\r\npublic class Foo {\r\n\tprivate final int value;\r\n\r\n\tpublic static class FooBuilder {\r\n\t\tpublic FooBuilder valueAsString(String s) {\r\n\t\t\treturn this.value(Integer.parseInt(s));\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\n### Working alternative 2:\r\n\r\n```java\r\n@lombok.Builder\r\npublic class Foo {\r\n\tprivate final int value;\r\n\r\n\tpublic static class FooBuilder {\r\n\t\tpublic FooBuilder value(String s) {\r\n\t\t\treturn this.value(Integer.parseInt(s));\r\n\t\t}\r\n\r\n\t\tpublic FooBuilder value(int value) {\r\n\t\t\tthis.value = value;\r\n\t\t\treturn this;\r\n\t\t}\r\n\t}\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/rzwitserloot/lombok/issues/comments/260230361","html_url":"https://github.com/rzwitserloot/lombok/issues/1230#issuecomment-260230361","issue_url":"https://api.github.com/repos/rzwitserloot/lombok/issues/1230","id":260230361,"user":{"login":"nakagawa-atsushi","id":16129867,"avatar_url":"https://avatars.githubusercontent.com/u/16129867?v=3","gravatar_id":"","url":"https://api.github.com/users/nakagawa-atsushi","html_url":"https://github.com/nakagawa-atsushi","followers_url":"https://api.github.com/users/nakagawa-atsushi/followers","following_url":"https://api.github.com/users/nakagawa-atsushi/following{/other_user}","gists_url":"https://api.github.com/users/nakagawa-atsushi/gists{/gist_id}","starred_url":"https://api.github.com/users/nakagawa-atsushi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nakagawa-atsushi/subscriptions","organizations_url":"https://api.github.com/users/nakagawa-atsushi/orgs","repos_url":"https://api.github.com/users/nakagawa-atsushi/repos","events_url":"https://api.github.com/users/nakagawa-atsushi/events{/privacy}","received_events_url":"https://api.github.com/users/nakagawa-atsushi/received_events","type":"User","site_admin":false},"created_at":"2016-11-14T01:41:35Z","updated_at":"2016-11-14T01:41:35Z","body":"> But I think it is no good idea. Maybe we should try to improve the builder code to support such behavior without @Tolerate?\r\n\r\nIf you mean to do this by comparing parameter types to check whether the same [method signature](https://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.4.2) exists, I agree that's a better idea.\r\n\r\nI think the same however can be said about `@Getter` / `@Setter` / `@Wither`."}}
{"actor":{"display_login":"nakagawa-atsushi"}}