{"action":"created","issue":{"url":"https://api.github.com/repos/SimonVT/schematic/issues/43","labels_url":"https://api.github.com/repos/SimonVT/schematic/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/SimonVT/schematic/issues/43/comments","events_url":"https://api.github.com/repos/SimonVT/schematic/issues/43/events","html_url":"https://github.com/SimonVT/schematic/issues/43","id":124468802,"number":43,"title":"Proposal: helper to retrieve column value from cursor","user":{"login":"MyDogTom","id":5940462,"avatar_url":"https://avatars.githubusercontent.com/u/5940462?v=3","gravatar_id":"","url":"https://api.github.com/users/MyDogTom","html_url":"https://github.com/MyDogTom","followers_url":"https://api.github.com/users/MyDogTom/followers","following_url":"https://api.github.com/users/MyDogTom/following{/other_user}","gists_url":"https://api.github.com/users/MyDogTom/gists{/gist_id}","starred_url":"https://api.github.com/users/MyDogTom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MyDogTom/subscriptions","organizations_url":"https://api.github.com/users/MyDogTom/orgs","repos_url":"https://api.github.com/users/MyDogTom/repos","events_url":"https://api.github.com/users/MyDogTom/events{/privacy}","received_events_url":"https://api.github.com/users/MyDogTom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-31T12:57:06Z","updated_at":"2016-01-02T22:18:45Z","closed_at":null,"body":"\r\nHi, @SimonVT .\r\nI'm thinking about creating merge request with \"column getter\" functionality (see description below). Please tell me if it suitable for library or not.\r\n \r\nMotivation: Instead of writing `String note = cursor.getString(cursor.getColumnIndex(NoteColumns.NOTE));` just call `String note = NotesGetter.noteString(cursor);`. It's more significant when you deal with nullable columns.\r\n\r\nCouple details about suggested implementation:\r\n* Use `getColumnIndexOrThrow` instead of `getColumnIndex`. I think this approach is more robust because let identify problems earlier.\r\n* Create implementation for all primitive types and for wrappers. Support `null` for wrappers. Example of generated code.\r\n````\r\n  public static Integer getIdIntOrNull(Cursor cursor) {\r\n    int index = cursor.getColumnIndexOrThrow(NoteColumns.ID);\r\n    if (cursor.isNull(index)) {\r\n      return null;\r\n    } else {\r\n      return cursor.getInt(index);\r\n    }\r\n  }\r\n\r\n  public int getIdInt(Cursor cursor) {\r\n    return cursor.getInt(cursor.getColumnIndexOrThrow(NoteColumns.ID));\r\n  }\r\n````\r\n* I'll always generate `null` support despite `@NotNull` annotation.\r\n* I'm still looking for better class and method names."},"comment":{"url":"https://api.github.com/repos/SimonVT/schematic/issues/comments/168434965","html_url":"https://github.com/SimonVT/schematic/issues/43#issuecomment-168434965","issue_url":"https://api.github.com/repos/SimonVT/schematic/issues/43","id":168434965,"user":{"login":"SimonVT","id":549365,"avatar_url":"https://avatars.githubusercontent.com/u/549365?v=3","gravatar_id":"","url":"https://api.github.com/users/SimonVT","html_url":"https://github.com/SimonVT","followers_url":"https://api.github.com/users/SimonVT/followers","following_url":"https://api.github.com/users/SimonVT/following{/other_user}","gists_url":"https://api.github.com/users/SimonVT/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonVT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonVT/subscriptions","organizations_url":"https://api.github.com/users/SimonVT/orgs","repos_url":"https://api.github.com/users/SimonVT/repos","events_url":"https://api.github.com/users/SimonVT/events{/privacy}","received_events_url":"https://api.github.com/users/SimonVT/received_events","type":"User","site_admin":false},"created_at":"2016-01-02T22:18:44Z","updated_at":"2016-01-02T22:18:44Z","body":"Added the helper class in e020ecb at least. I think having `idLong()`, `idInt()`, etc, methods is kind of ugly, and I don't really want to make the `@DataType` any more specific.\r\n\r\nWill keep it open in case someone comes up with an awesome solution."}}