{"action":"opened","issue":{"url":"https://api.github.com/repos/jooby-project/jooby/issues/408","repository_url":"https://api.github.com/repos/jooby-project/jooby","labels_url":"https://api.github.com/repos/jooby-project/jooby/issues/408/labels{/name}","comments_url":"https://api.github.com/repos/jooby-project/jooby/issues/408/comments","events_url":"https://api.github.com/repos/jooby-project/jooby/issues/408/events","html_url":"https://github.com/jooby-project/jooby/issues/408","id":163481703,"number":408,"title":"bean parser: support null values ","user":{"login":"jknack","id":1301129,"avatar_url":"https://avatars.githubusercontent.com/u/1301129?v=3","gravatar_id":"","url":"https://api.github.com/users/jknack","html_url":"https://github.com/jknack","followers_url":"https://api.github.com/users/jknack/followers","following_url":"https://api.github.com/users/jknack/following{/other_user}","gists_url":"https://api.github.com/users/jknack/gists{/gist_id}","starred_url":"https://api.github.com/users/jknack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jknack/subscriptions","organizations_url":"https://api.github.com/users/jknack/orgs","repos_url":"https://api.github.com/users/jknack/repos","events_url":"https://api.github.com/users/jknack/events{/privacy}","received_events_url":"https://api.github.com/users/jknack/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-01T22:04:33Z","updated_at":"2016-07-01T22:04:33Z","closed_at":null,"body":"Nullability across the framework is expressed using the ```java.util.Optional``` class. This is/was a right choice and let users to quickly identify where an optional value might occurs.\r\n\r\nSuppose you have a ```form``` that will post a Book object with a ```title``` an optional ```releaseDate```, you can express this like:\r\n\r\n```java\r\npublic class Book {\r\n  public String title;\r\n  public Optional<Date> releaseDate;\r\n}\r\n\r\n{\r\n  post(\"/book\", req -> {\r\n   Book book = req.params(Book.class);\r\n  });\r\n}\r\n```\r\n\r\nThis is nice, clean and add semantic to your business. Book is telling you that releaseDate might not be present.. which is very nice!\r\n\r\n...Still, due that ```Optional``` was a recent addition to java... isn't widely used it by Java developers... So that is why we are going to support ```null values``` when user explicitly ask for it:\r\n\r\n```java\r\n{\r\n  // true means allowNulls\r\n  parser(Parser.bean(true));\r\n\r\n  post(\"/book\", req -> {\r\n   Book book = req.params(Book.class);\r\n  });\r\n}\r\n```\r\n\r\nSo, now you can use ```Date releaseDate```` instead of ```Optional<Date> releaseDate```\r\n\r\nSource: https://groups.google.com/forum/#!topic/jooby-project/fyjwuXUxjfY\r\n/cc @kshep92"}}
{"actor":{"display_login":"jknack"}}