{"action":"created","issue":{"url":"https://api.github.com/repos/square/javapoet/issues/428","repository_url":"https://api.github.com/repos/square/javapoet","labels_url":"https://api.github.com/repos/square/javapoet/issues/428/labels{/name}","comments_url":"https://api.github.com/repos/square/javapoet/issues/428/comments","events_url":"https://api.github.com/repos/square/javapoet/issues/428/events","html_url":"https://github.com/square/javapoet/pull/428","id":133195185,"number":428,"title":"ClassName.canonical and TypeName.binary()","user":{"login":"sormuras","id":2319838,"avatar_url":"https://avatars.githubusercontent.com/u/2319838?v=3","gravatar_id":"","url":"https://api.github.com/users/sormuras","html_url":"https://github.com/sormuras","followers_url":"https://api.github.com/users/sormuras/followers","following_url":"https://api.github.com/users/sormuras/following{/other_user}","gists_url":"https://api.github.com/users/sormuras/gists{/gist_id}","starred_url":"https://api.github.com/users/sormuras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sormuras/subscriptions","organizations_url":"https://api.github.com/users/sormuras/orgs","repos_url":"https://api.github.com/users/sormuras/repos","events_url":"https://api.github.com/users/sormuras/events{/privacy}","received_events_url":"https://api.github.com/users/sormuras/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-12T09:36:07Z","updated_at":"2016-02-15T06:31:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/square/javapoet/pulls/428","html_url":"https://github.com/square/javapoet/pull/428","diff_url":"https://github.com/square/javapoet/pull/428.diff","patch_url":"https://github.com/square/javapoet/pull/428.patch"},"body":" * Published immutable `ClassName.canonicalName` and `ClassName.binaryName` fields.\r\n * Made `TypeName` report its binary name, which can be used in `Class.forName(className)` calls.\r\n\r\nThe test looks like:\r\n```java\r\nassertEquals(\"void\", TypeName.VOID.binary());\r\nassertEquals(\"int\", TypeName.INT.binary());\r\nassertEquals(\"java.lang.Object\", TypeName.OBJECT.binary());\r\nassertEquals(\"java.lang.Thread$State\", TypeName.get(Thread.State.class).binary());\r\nassertEquals(\"[java.util.Map$Entry;\", TypeName.get(Map.Entry[].class).binary());\r\nassertEquals(\"[[[Z\", TypeName.get(boolean[][][].class).binary());\r\nassertEquals(\"java.util.List\", ParameterizedTypeName.get(List.class, String.class).binary());\r\nassertEquals(\"java.util.Set\", ParameterizedTypeName.get(Set.class, UUID.class).binary());\r\n```\r\n\r\n* `TypeVariableName.binary()` and `WildcardTypeName.binary()` ~~should~~ throw `UnsupportedOperationException`!"},"comment":{"url":"https://api.github.com/repos/square/javapoet/issues/comments/184080734","html_url":"https://github.com/square/javapoet/pull/428#issuecomment-184080734","issue_url":"https://api.github.com/repos/square/javapoet/issues/428","id":184080734,"user":{"login":"sormuras","id":2319838,"avatar_url":"https://avatars.githubusercontent.com/u/2319838?v=3","gravatar_id":"","url":"https://api.github.com/users/sormuras","html_url":"https://github.com/sormuras","followers_url":"https://api.github.com/users/sormuras/followers","following_url":"https://api.github.com/users/sormuras/following{/other_user}","gists_url":"https://api.github.com/users/sormuras/gists{/gist_id}","starred_url":"https://api.github.com/users/sormuras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sormuras/subscriptions","organizations_url":"https://api.github.com/users/sormuras/orgs","repos_url":"https://api.github.com/users/sormuras/repos","events_url":"https://api.github.com/users/sormuras/events{/privacy}","received_events_url":"https://api.github.com/users/sormuras/received_events","type":"User","site_admin":false},"created_at":"2016-02-15T06:31:11Z","updated_at":"2016-02-15T06:31:11Z","body":"The use-case is the reversal of `TypeName.get(...)`. Sometimes, I need to check whether the type specified by a `TypeName` is a) findable, loadable and b) inspect some properties of the loaded class. Like `isEnum()` et al."}}