{"action":"created","issue":{"url":"https://api.github.com/repos/chrsmithdemos/google-api-java-client/issues/237","labels_url":"https://api.github.com/repos/chrsmithdemos/google-api-java-client/issues/237/labels{/name}","comments_url":"https://api.github.com/repos/chrsmithdemos/google-api-java-client/issues/237/comments","events_url":"https://api.github.com/repos/chrsmithdemos/google-api-java-client/issues/237/events","html_url":"https://github.com/chrsmithdemos/google-api-java-client/issues/237","id":59551470,"number":237,"title":"Allow annotation to specify a value-converter an @Key.","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chrsmithdemos/google-api-java-client/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/chrsmithdemos/google-api-java-client/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/chrsmithdemos/google-api-java-client/labels/Type-Enhancement","name":"Type-Enhancement","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-02T21:13:31Z","updated_at":"2015-03-02T21:13:32Z","closed_at":"2015-03-02T21:13:31Z","body":"```\nExternal references, such as a standards document, or specification?\nNone that I am aware of.\n\nJava environments (e.g. Java 6, Android 2.3, App Engine 1.4.2, or All)?\nAll.\n\nPlease describe the feature requested.\n\n// framework\n\n/**\n * Specifies a conversion.\n */\ninterface Converter<T> {\n   String toString(T obj);\n   T valueOf(String value) throws ParseException;\n}\n\n/** \n * Tell google-api-java-client to apply the specified conversion.\n */ \n@Retention(RetentionPolicy.RUNTIME)\n@Target(ElementType.FIELD)\npublic @interface Convert {\n   Class<? extends Converter> value();\n   // this is better than abusing @Key\n}\n\n\n\n// application example\n\nimport java.awt.Color;\n\nclass ColorConverter implements Converter<Color> {\n   // has parameterless default constructor\n   \n   @Override\n   public String toString(Color obj) {\n      // format\n   }\n   \n   @Override\n   public Color valueOf(String value) throws ParseException {\n      // parse\n   }\n}\n\nclass Calendar {\n @Key(\"gCal:color\")\n @Convert(ColorConverter.class)\n public Color color;\n}\n\n\n\n\nDesign notes:\n  The framework could inspect a Converter<T>'s method annotation to decide whether to invoke the method if the input is null.  This could spare Converter implementors from having to deal with null input.\n\n  A framework-provided \"abstract Class DefaultConverter implements Converter\" could be useful.\n\n  Parse errors should not stop reading input, but there probably needs to be a way to callback the caller of the parseAs() method.\n\n  The use-case anticipated here doesn't need control over *collections* (eg. @Key(\"entry\") List<Entry> entries;) ... this case can probably be excluded from the design of the Converter.\n\n  This converter doesn't solve more annoying issues like when the <entry/> of a calendar event feed specialises the <gd:comments/> element from the Event kind such that the <gd:feedLink/> points to a feed containing <entry/>s of the Message kind, and shouldn't try to.\n```\n\nOriginal issue reported on code.google.com by `dtbull...@gmail.com` on 21 Jun 2011 at 10:02"},"comment":{"url":"https://api.github.com/repos/chrsmithdemos/google-api-java-client/issues/comments/76824604","html_url":"https://github.com/chrsmithdemos/google-api-java-client/issues/237#issuecomment-76824604","issue_url":"https://api.github.com/repos/chrsmithdemos/google-api-java-client/issues/237","id":76824604,"user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"created_at":"2015-03-02T21:13:32Z","updated_at":"2015-03-02T21:13:32Z","body":"```\nVery interesting idea.  We should investigate how other JSON libraries like \nJackson and GSON handle this.\n```\n\nOriginal comment by `yan...@google.com` on 16 Aug 2011 at 2:45\n* Changed state: **Accepted**"}}