{"action":"created","issue":{"url":"https://api.github.com/repos/eclipse/smarthome/issues/4612","repository_url":"https://api.github.com/repos/eclipse/smarthome","labels_url":"https://api.github.com/repos/eclipse/smarthome/issues/4612/labels{/name}","comments_url":"https://api.github.com/repos/eclipse/smarthome/issues/4612/comments","events_url":"https://api.github.com/repos/eclipse/smarthome/issues/4612/events","html_url":"https://github.com/eclipse/smarthome/issues/4612","id":276282674,"number":4612,"title":"Factory methods for State","user":{"login":"martinvw","id":2625279,"avatar_url":"https://avatars3.githubusercontent.com/u/2625279?v=4","gravatar_id":"","url":"https://api.github.com/users/martinvw","html_url":"https://github.com/martinvw","followers_url":"https://api.github.com/users/martinvw/followers","following_url":"https://api.github.com/users/martinvw/following{/other_user}","gists_url":"https://api.github.com/users/martinvw/gists{/gist_id}","starred_url":"https://api.github.com/users/martinvw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinvw/subscriptions","organizations_url":"https://api.github.com/users/martinvw/orgs","repos_url":"https://api.github.com/users/martinvw/repos","events_url":"https://api.github.com/users/martinvw/events{/privacy}","received_events_url":"https://api.github.com/users/martinvw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-11-23T07:18:16Z","updated_at":"2017-12-01T23:17:47Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I noticed that quite some bindings have there own utility class / methods to do a null check and conditionally convert it to either ~~`UnDefType.NULL`~~ _(edit: `UnDefType.UNDEF`)_ or the respective value, some examples:\r\n\r\n[netatmo ChannelTypeUtils](https://github.com/openhab/openhab2-addons/blob/master/addons/binding/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/ChannelTypeUtils.java)\r\n[NestBaseHandler @ line 109](https://github.com/openhab/openhab2-addons/blob/8f7c32ce13b89e0bd913758e158b5b55eae7ecd6/addons/binding/org.openhab.binding.nest/src/main/java/org/openhab/binding/nest/handler/NestBaseHandler.java#L109)\r\n[KodiHandler.java @ Line 399](https://github.com/openhab/openhab2-addons/blob/f238e11e8b61def4d1247e37df32be45a319377f/addons/binding/org.openhab.binding.kodi/src/main/java/org/openhab/binding/kodi/handler/KodiHandler.java#L399)\r\n\r\nI think that this should/could be the responsibility of the framework, imho every method (for which it is sensible) should have one or more nullable `valueOf` methods. Which return either ~~`UnDefType.NULL`~~ _(edit: `UnDefType.UNDEF`)_ or the wrapper class of the requested type.\r\n\r\nI would also suggest to change the meaning of [DecimalType.valueOf](https://github.com/eclipse/smarthome/blob/36c9e2717e4f89cf60a0d885e7ecc6069b338f48/bundles/core/org.eclipse.smarthome.core/src/main/java/org/eclipse/smarthome/core/library/types/DecimalType.java#L68) to allow null and handle it properly.\r\n\r\nI can / would like to make this PR but if people already reject it would be waste of time, so what do you think?\r\n\r\nCC: @maggu2810 @sjka @htreu \r\n\r\nPS: maybe I would even like to mark the constructors deprecated for touched classes..."},"comment":{"url":"https://api.github.com/repos/eclipse/smarthome/issues/comments/348639814","html_url":"https://github.com/eclipse/smarthome/issues/4612#issuecomment-348639814","issue_url":"https://api.github.com/repos/eclipse/smarthome/issues/4612","id":348639814,"user":{"login":"kaikreuzer","id":3244965,"avatar_url":"https://avatars3.githubusercontent.com/u/3244965?v=4","gravatar_id":"","url":"https://api.github.com/users/kaikreuzer","html_url":"https://github.com/kaikreuzer","followers_url":"https://api.github.com/users/kaikreuzer/followers","following_url":"https://api.github.com/users/kaikreuzer/following{/other_user}","gists_url":"https://api.github.com/users/kaikreuzer/gists{/gist_id}","starred_url":"https://api.github.com/users/kaikreuzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaikreuzer/subscriptions","organizations_url":"https://api.github.com/users/kaikreuzer/orgs","repos_url":"https://api.github.com/users/kaikreuzer/repos","events_url":"https://api.github.com/users/kaikreuzer/events{/privacy}","received_events_url":"https://api.github.com/users/kaikreuzer/received_events","type":"User","site_admin":false},"created_at":"2017-12-01T23:17:46Z","updated_at":"2017-12-01T23:17:46Z","author_association":"MEMBER","body":"As mentioned above: The original idea was to say that UNDEF stands for \"there is a state, but I cannot express it\" - e.g. because you ask to retrieve a 50% state as an OpenClosedType.\r\nNULL was meant to have the very same meaning as \"null\" in Java, i.e. \"there is nothing / no state at all\".\r\n\r\n> So, if there is no \"current artist\" we could also set undefined\r\n\r\n... while NULL would be the better match.\r\n\r\n> it feels good to have a separation between what he framework sets and what bindings could /should set.\r\n\r\nIf you can replace this \"feeling\" by some objective arguments why this separation is a good thing, I might be tempted to give in. But for the moment, I am not yet convinced, sorry ;-)"}}
{"actor":{"display_login":"kaikreuzer"}}