GitHub PullRequestReviewCommentEvent at 2014-07-18 15:21:50
Repository: hibernate-validator
Actor: khalidq
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/comments/15116639","id":15116639,"diff_hunk":"@@ -0,0 +1,309 @@\n+/*\n+* JBoss, Home of Professional Open Source\n+* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual contributors\n+* by the @authors tag. See the copyright.txt in the distribution for a\n+* full listing of individual contributors.\n+*\n+* Licensed under the Apache License, Version 2.0 (the \"License\");\n+* you may not use this file except in compliance with the License.\n+* You may obtain a copy of the License at\n+* http://www.apache.org/licenses/LICENSE-2.0\n+* Unless required by applicable law or agreed to in writing, software\n+* distributed under the License is distributed on an \"AS IS\" BASIS,\n+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+* See the License for the specific language governing permissions and\n+* limitations under the License.\n+*/\n+package org.hibernate.validator.internal.metadata.provider;\n+\n+import java.lang.annotation.Annotation;\n+import java.lang.annotation.ElementType;\n+import java.lang.reflect.AnnotatedType;\n+import java.lang.reflect.Executable;\n+import java.lang.reflect.Field;\n+import java.lang.reflect.Member;\n+import java.lang.reflect.Type;\n+import java.lang.reflect.TypeVariable;\n+import java.util.Collections;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Set;\n+import javax.validation.ParameterNameProvider;\n+\n+import org.hibernate.validator.internal.metadata.core.AnnotationProcessingOptions;\n+import org.hibernate.validator.internal.metadata.core.ConstraintHelper;\n+import org.hibernate.validator.internal.metadata.core.MetaConstraint;\n+import org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl;\n+import org.hibernate.validator.internal.metadata.location.ConstraintLocation;\n+import org.hibernate.validator.internal.metadata.raw.BeanConfiguration;\n+import org.hibernate.validator.internal.metadata.raw.ExecutableElement;\n+import org.hibernate.validator.internal.util.ReflectionHelper;\n+import org.hibernate.validator.internal.util.TypeHelper;\n+import org.hibernate.validator.internal.util.TypeUseHelper;\n+import org.hibernate.validator.internal.util.classhierarchy.ClassHierarchyHelper;\n+\n+import static org.hibernate.validator.internal.util.CollectionHelper.newArrayList;\n+import static org.hibernate.validator.internal.util.CollectionHelper.newHashMap;\n+import static org.hibernate.validator.internal.util.CollectionHelper.newHashSet;\n+\n+/**\n+ * Extends the base {@code AnnotationMetaDataProvider} with the following:\n+ *\n+ * <ul>\n+ *     <li>Discover and register constraints defined on formal parameters and actual type arguments.</li>\n+ *     <li>Discover and register constraints defined on type arguments for fields, parameters, and return\n+ *     values parameterized types.</li>\n+ * </ul>\n+ *\n+ * @author Khalid Alqinyah\n+ */\n+public class EnhancedAnnotationMetaDataProvider extends AnnotationMetaDataProvider {\n+\n+\t/**\n+\t * Keeps track of discovered annotations on formal parameters and actual type arguments for the current hierarchy.\n+\t */\n+\tprivate Map<TypeVariable<?>, Set<Annotation>> typeUseConstraintsMap = newHashMap();","path":"engine/src/main/java/org/hibernate/validator/internal/metadata/provider/EnhancedAnnotationMetaDataProvider.java","position":65,"original_position":65,"commit_id":"9957d05e222d00172680044a8a3a3c9c74fdb82b","original_commit_id":"9957d05e222d00172680044a8a3a3c9c74fdb82b","user":{"login":"khalidq","id":3060068,"avatar_url":"https://avatars.githubusercontent.com/u/3060068?","gravatar_id":"5f1948099c402ff11e3ab09eb9e380dd","url":"https://api.github.com/users/khalidq","html_url":"https://github.com/khalidq","followers_url":"https://api.github.com/users/khalidq/followers","following_url":"https://api.github.com/users/khalidq/following{/other_user}","gists_url":"https://api.github.com/users/khalidq/gists{/gist_id}","starred_url":"https://api.github.com/users/khalidq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khalidq/subscriptions","organizations_url":"https://api.github.com/users/khalidq/orgs","repos_url":"https://api.github.com/users/khalidq/repos","events_url":"https://api.github.com/users/khalidq/events{/privacy}","received_events_url":"https://api.github.com/users/khalidq/received_events","type":"User","site_admin":false},"body":"@gunnarmorling, I'm a bit stuck. I created a local map and passed it around to map the discovered type use annotations. Discovery and mapping wasn't a problem since I control the method parameters, and I can pass the map.\r\n\r\nBut the overridden methods from `AnnotationMetaDataProvider` have no access to the map, so, I'm unable to find a match to the current field, method, or parameter type.\r\n\r\nI have some exotic solutions like passing an empty map in `AnnotationMetaDataProvider`, or creating a locked global variable in `EnhancedAnnotationMetaDataProvider` where only the current thread can access the map. But I'm not sure these solutions are ideal.\r\n\r\nAny suggestions?","created_at":"2014-07-18T15:21:50Z","updated_at":"2014-07-18T15:21:50Z","html_url":"https://github.com/hibernate/hibernate-validator/pull/326#discussion_r15116639","pull_request_url":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/326","_links":{"self":{"href":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/comments/15116639"},"html":{"href":"https://github.com/hibernate/hibernate-validator/pull/326#discussion_r15116639"},"pull_request":{"href":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/326"}}},"pull_request":{"url":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/326","id":18497415,"html_url":"https://github.com/hibernate/hibernate-validator/pull/326","diff_url":"https://github.com/hibernate/hibernate-validator/pull/326.diff","patch_url":"https://github.com/hibernate/hibernate-validator/pull/326.patch","issue_url":"https://api.github.com/repos/hibernate/hibernate-validator/issues/326","number":326,"state":"open","title":"HV-877 Discovering and registering type use constraints","user":{"login":"khalidq","id":3060068,"avatar_url":"https://avatars.githubusercontent.com/u/3060068?","gravatar_id":"5f1948099c402ff11e3ab09eb9e380dd","url":"https://api.github.com/users/khalidq","html_url":"https://github.com/khalidq","followers_url":"https://api.github.com/users/khalidq/followers","following_url":"https://api.github.com/users/khalidq/following{/other_user}","gists_url":"https://api.github.com/users/khalidq/gists{/gist_id}","starred_url":"https://api.github.com/users/khalidq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khalidq/subscriptions","organizations_url":"https://api.github.com/users/khalidq/orgs","repos_url":"https://api.github.com/users/khalidq/repos","events_url":"https://api.github.com/users/khalidq/events{/privacy}","received_events_url":"https://api.github.com/users/khalidq/received_events","type":"User","site_admin":false},"body":"A bit smaller. This PR focuses on discovering and registering type use constraints for the base use cases. \r\n\r\nCascaded type usage, and the actual validation of the constraints will be in separate PRs to make things easier to track.\r\n\r\nNote: you'll need Java 8u20 for this to work. There is a bug with parameters annotated types with earlier JDKs.","created_at":"2014-07-16T21:46:26Z","updated_at":"2014-07-18T15:21:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"234228036992a42c169f2ce955ed08fa4178c66c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/326/commits","review_comments_url":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/326/comments","review_comment_url":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/comments/{number}","comments_url":"https://api.github.com/repos/hibernate/hibernate-validator/issues/326/comments","statuses_url":"https://api.github.com/repos/hibernate/hibernate-validator/statuses/9957d05e222d00172680044a8a3a3c9c74fdb82b","head":{"label":"khalidq:HV-877","ref":"HV-877","sha":"9957d05e222d00172680044a8a3a3c9c74fdb82b","user":{"login":"khalidq","id":3060068,"avatar_url":"https://avatars.githubusercontent.com/u/3060068?","gravatar_id":"5f1948099c402ff11e3ab09eb9e380dd","url":"https://api.github.com/users/khalidq","html_url":"https://github.com/khalidq","followers_url":"https://api.github.com/users/khalidq/followers","following_url":"https://api.github.com/users/khalidq/following{/other_user}","gists_url":"https://api.github.com/users/khalidq/gists{/gist_id}","starred_url":"https://api.github.com/users/khalidq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khalidq/subscriptions","organizations_url":"https://api.github.com/users/khalidq/orgs","repos_url":"https://api.github.com/users/khalidq/repos","events_url":"https://api.github.com/users/khalidq/events{/privacy}","received_events_url":"https://api.github.com/users/khalidq/received_events","type":"User","site_admin":false},"repo":{"id":17596698,"name":"hibernate-validator","full_name":"khalidq/hibernate-validator","owner":{"login":"khalidq","id":3060068,"avatar_url":"https://avatars.githubusercontent.com/u/3060068?","gravatar_id":"5f1948099c402ff11e3ab09eb9e380dd","url":"https://api.github.com/users/khalidq","html_url":"https://github.com/khalidq","followers_url":"https://api.github.com/users/khalidq/followers","following_url":"https://api.github.com/users/khalidq/following{/other_user}","gists_url":"https://api.github.com/users/khalidq/gists{/gist_id}","starred_url":"https://api.github.com/users/khalidq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khalidq/subscriptions","organizations_url":"https://api.github.com/users/khalidq/orgs","repos_url":"https://api.github.com/users/khalidq/repos","events_url":"https://api.github.com/users/khalidq/events{/privacy}","received_events_url":"https://api.github.com/users/khalidq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/khalidq/hibernate-validator","description":"Hibernate Validator - Bean Validation 1.1 (JSR 349) Reference Implementation","fork":true,"url":"https://api.github.com/repos/khalidq/hibernate-validator","forks_url":"https://api.github.com/repos/khalidq/hibernate-validator/forks","keys_url":"https://api.github.com/repos/khalidq/hibernate-validator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/khalidq/hibernate-validator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/khalidq/hibernate-validator/teams","hooks_url":"https://api.github.com/repos/khalidq/hibernate-validator/hooks","issue_events_url":"https://api.github.com/repos/khalidq/hibernate-validator/issues/events{/number}","events_url":"https://api.github.com/repos/khalidq/hibernate-validator/events","assignees_url":"https://api.github.com/repos/khalidq/hibernate-validator/assignees{/user}","branches_url":"https://api.github.com/repos/khalidq/hibernate-validator/branches{/branch}","tags_url":"https://api.github.com/repos/khalidq/hibernate-validator/tags","blobs_url":"https://api.github.com/repos/khalidq/hibernate-validator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/khalidq/hibernate-validator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/khalidq/hibernate-validator/git/refs{/sha}","trees_url":"https://api.github.com/repos/khalidq/hibernate-validator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/khalidq/hibernate-validator/statuses/{sha}","languages_url":"https://api.github.com/repos/khalidq/hibernate-validator/languages","stargazers_url":"https://api.github.com/repos/khalidq/hibernate-validator/stargazers","contributors_url":"https://api.github.com/repos/khalidq/hibernate-validator/contributors","subscribers_url":"https://api.github.com/repos/khalidq/hibernate-validator/subscribers","subscription_url":"https://api.github.com/repos/khalidq/hibernate-validator/subscription","commits_url":"https://api.github.com/repos/khalidq/hibernate-validator/commits{/sha}","git_commits_url":"https://api.github.com/repos/khalidq/hibernate-validator/git/commits{/sha}","comments_url":"https://api.github.com/repos/khalidq/hibernate-validator/comments{/number}","issue_comment_url":"https://api.github.com/repos/khalidq/hibernate-validator/issues/comments/{number}","contents_url":"https://api.github.com/repos/khalidq/hibernate-validator/contents/{+path}","compare_url":"https://api.github.com/repos/khalidq/hibernate-validator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/khalidq/hibernate-validator/merges","archive_url":"https://api.github.com/repos/khalidq/hibernate-validator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/khalidq/hibernate-validator/downloads","issues_url":"https://api.github.com/repos/khalidq/hibernate-validator/issues{/number}","pulls_url":"https://api.github.com/repos/khalidq/hibernate-validator/pulls{/number}","milestones_url":"https://api.github.com/repos/khalidq/hibernate-validator/milestones{/number}","notifications_url":"https://api.github.com/repos/khalidq/hibernate-validator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/khalidq/hibernate-validator/labels{/name}","releases_url":"https://api.github.com/repos/khalidq/hibernate-validator/releases{/id}","created_at":"2014-03-10T15:01:50Z","updated_at":"2014-06-30T16:36:52Z","pushed_at":"2014-07-16T21:35:53Z","git_url":"git://github.com/khalidq/hibernate-validator.git","ssh_url":"git@github.com:khalidq/hibernate-validator.git","clone_url":"https://github.com/khalidq/hibernate-validator.git","svn_url":"https://github.com/khalidq/hibernate-validator","homepage":"http://validator.hibernate.org/","size":19249,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hibernate:master","ref":"master","sha":"1d6d3f5be47a90d9bfa8532e09018be3a927569e","user":{"login":"hibernate","id":348262,"avatar_url":"https://avatars.githubusercontent.com/u/348262?","gravatar_id":"ce9572f319e848be149196b772776981","url":"https://api.github.com/users/hibernate","html_url":"https://github.com/hibernate","followers_url":"https://api.github.com/users/hibernate/followers","following_url":"https://api.github.com/users/hibernate/following{/other_user}","gists_url":"https://api.github.com/users/hibernate/gists{/gist_id}","starred_url":"https://api.github.com/users/hibernate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hibernate/subscriptions","organizations_url":"https://api.github.com/users/hibernate/orgs","repos_url":"https://api.github.com/users/hibernate/repos","events_url":"https://api.github.com/users/hibernate/events{/privacy}","received_events_url":"https://api.github.com/users/hibernate/received_events","type":"Organization","site_admin":false},"repo":{"id":972205,"name":"hibernate-validator","full_name":"hibernate/hibernate-validator","owner":{"login":"hibernate","id":348262,"avatar_url":"https://avatars.githubusercontent.com/u/348262?","gravatar_id":"ce9572f319e848be149196b772776981","url":"https://api.github.com/users/hibernate","html_url":"https://github.com/hibernate","followers_url":"https://api.github.com/users/hibernate/followers","following_url":"https://api.github.com/users/hibernate/following{/other_user}","gists_url":"https://api.github.com/users/hibernate/gists{/gist_id}","starred_url":"https://api.github.com/users/hibernate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hibernate/subscriptions","organizations_url":"https://api.github.com/users/hibernate/orgs","repos_url":"https://api.github.com/users/hibernate/repos","events_url":"https://api.github.com/users/hibernate/events{/privacy}","received_events_url":"https://api.github.com/users/hibernate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hibernate/hibernate-validator","description":"Hibernate Validator - Bean Validation 1.1 (JSR 349) Reference Implementation","fork":false,"url":"https://api.github.com/repos/hibernate/hibernate-validator","forks_url":"https://api.github.com/repos/hibernate/hibernate-validator/forks","keys_url":"https://api.github.com/repos/hibernate/hibernate-validator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hibernate/hibernate-validator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hibernate/hibernate-validator/teams","hooks_url":"https://api.github.com/repos/hibernate/hibernate-validator/hooks","issue_events_url":"https://api.github.com/repos/hibernate/hibernate-validator/issues/events{/number}","events_url":"https://api.github.com/repos/hibernate/hibernate-validator/events","assignees_url":"https://api.github.com/repos/hibernate/hibernate-validator/assignees{/user}","branches_url":"https://api.github.com/repos/hibernate/hibernate-validator/branches{/branch}","tags_url":"https://api.github.com/repos/hibernate/hibernate-validator/tags","blobs_url":"https://api.github.com/repos/hibernate/hibernate-validator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hibernate/hibernate-validator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hibernate/hibernate-validator/git/refs{/sha}","trees_url":"https://api.github.com/repos/hibernate/hibernate-validator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hibernate/hibernate-validator/statuses/{sha}","languages_url":"https://api.github.com/repos/hibernate/hibernate-validator/languages","stargazers_url":"https://api.github.com/repos/hibernate/hibernate-validator/stargazers","contributors_url":"https://api.github.com/repos/hibernate/hibernate-validator/contributors","subscribers_url":"https://api.github.com/repos/hibernate/hibernate-validator/subscribers","subscription_url":"https://api.github.com/repos/hibernate/hibernate-validator/subscription","commits_url":"https://api.github.com/repos/hibernate/hibernate-validator/commits{/sha}","git_commits_url":"https://api.github.com/repos/hibernate/hibernate-validator/git/commits{/sha}","comments_url":"https://api.github.com/repos/hibernate/hibernate-validator/comments{/number}","issue_comment_url":"https://api.github.com/repos/hibernate/hibernate-validator/issues/comments/{number}","contents_url":"https://api.github.com/repos/hibernate/hibernate-validator/contents/{+path}","compare_url":"https://api.github.com/repos/hibernate/hibernate-validator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hibernate/hibernate-validator/merges","archive_url":"https://api.github.com/repos/hibernate/hibernate-validator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hibernate/hibernate-validator/downloads","issues_url":"https://api.github.com/repos/hibernate/hibernate-validator/issues{/number}","pulls_url":"https://api.github.com/repos/hibernate/hibernate-validator/pulls{/number}","milestones_url":"https://api.github.com/repos/hibernate/hibernate-validator/milestones{/number}","notifications_url":"https://api.github.com/repos/hibernate/hibernate-validator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hibernate/hibernate-validator/labels{/name}","releases_url":"https://api.github.com/repos/hibernate/hibernate-validator/releases{/id}","created_at":"2010-10-08T13:25:07Z","updated_at":"2014-07-16T23:24:42Z","pushed_at":"2014-07-16T12:54:43Z","git_url":"git://github.com/hibernate/hibernate-validator.git","ssh_url":"git@github.com:hibernate/hibernate-validator.git","clone_url":"https://github.com/hibernate/hibernate-validator.git","svn_url":"https://github.com/hibernate/hibernate-validator","homepage":"http://validator.hibernate.org/","size":25649,"stargazers_count":114,"watchers_count":114,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":false,"forks_count":73,"mirror_url":null,"open_issues_count":3,"forks":73,"open_issues":3,"watchers":114,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/326"},"html":{"href":"https://github.com/hibernate/hibernate-validator/pull/326"},"issue":{"href":"https://api.github.com/repos/hibernate/hibernate-validator/issues/326"},"comments":{"href":"https://api.github.com/repos/hibernate/hibernate-validator/issues/326/comments"},"review_comments":{"href":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/326/comments"},"review_comment":{"href":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/hibernate/hibernate-validator/pulls/326/commits"},"statuses":{"href":"https://api.github.com/repos/hibernate/hibernate-validator/statuses/9957d05e222d00172680044a8a3a3c9c74fdb82b"}}}}