{"action":"created","comment":{"url":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/comments/157371967","pull_request_review_id":84003782,"id":157371967,"diff_hunk":"@@ -0,0 +1,86 @@\n+package ru.spbau.mit.alyokhina;\n+\n+import java.lang.reflect.Constructor;\n+import java.lang.reflect.InvocationTargetException;\n+import java.util.*;\n+import java.util.stream.Collectors;\n+\n+public class Injector {\n+    public static Object initialize(String rootClassName, List<String> parametrs) throws ImplementationNotFoundException, ClassNotFoundException,NoSuchMethodException, InstantiationException, InvocationTargetException, IllegalAccessException, InjectionCycleException{\n+        Class<?> rootClass;\n+        try{\n+            rootClass = Class.forName(rootClassName);\n+        }\n+        catch (ClassNotFoundException e) {\n+            System.out.println(e.getMessage());\n+            throw e;\n+        }\n+\n+        List<Class<?>> paramClass = parametrs.stream().map(x -> {\n+            try {\n+                return Class.forName(x);\n+            }\n+            catch (ClassNotFoundException e) {\n+                System.out.println(e.getMessage());\n+                throw new ClassCastException(e.getMessage());\n+            }\n+        }).collect(Collectors.toList());\n+        paramClass.add(rootClass);\n+        Map<Class<?>, Object> tmp = new HashMap<>();\n+        HashSet<String> visit = new HashSet<>();\n+        return  dfs(rootClass,paramClass, tmp, visit);\n+    }\n+\n+    private static Object dfs(Class<?> curClass, List<Class<?>> impl,  Map<Class<?>, Object> have, HashSet<String> visit) throws ImplementationNotFoundException, NoSuchMethodException, InstantiationException, InvocationTargetException, IllegalAccessException, InjectionCycleException{\n+        if (visit.contains(curClass.getName())) {\n+            throw new InjectionCycleException();\n+        }\n+        visit.add(curClass.getName());\n+        if (have.containsKey(curClass)) {\n+            return have.get(curClass);\n+        }\n+        else {\n+            Constructor<?> constructor = (curClass.getDeclaredConstructors())[0];\n+            Class<?>[] classParam = constructor.getParameterTypes();\n+            List<Object> forConstructor = new ArrayList<>();\n+            for (Class<?> i : classParam) {\n+                Class<?> c = getClass(i, impl);","path":"Test2/src/main/java/ru/spbau/mit/alyokhina/Injector.java","position":47,"original_position":47,"commit_id":"218c8be19dd5f4303a84b33b4b32b31a7ac155c0","original_commit_id":"218c8be19dd5f4303a84b33b4b32b31a7ac155c0","user":{"login":"jzuken","id":705678,"avatar_url":"https://avatars1.githubusercontent.com/u/705678?v=4","gravatar_id":"","url":"https://api.github.com/users/jzuken","html_url":"https://github.com/jzuken","followers_url":"https://api.github.com/users/jzuken/followers","following_url":"https://api.github.com/users/jzuken/following{/other_user}","gists_url":"https://api.github.com/users/jzuken/gists{/gist_id}","starred_url":"https://api.github.com/users/jzuken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzuken/subscriptions","organizations_url":"https://api.github.com/users/jzuken/orgs","repos_url":"https://api.github.com/users/jzuken/repos","events_url":"https://api.github.com/users/jzuken/events{/privacy}","received_events_url":"https://api.github.com/users/jzuken/received_events","type":"User","site_admin":false},"body":"а оно может и не найти ничего. тогда надо было бы ImplementationNotFoundException бросать","created_at":"2017-12-17T15:50:02Z","updated_at":"2017-12-17T15:58:13Z","html_url":"https://github.com/alyokhina-olya/JavaHW/pull/12#discussion_r157371967","pull_request_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/12","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/comments/157371967"},"html":{"href":"https://github.com/alyokhina-olya/JavaHW/pull/12#discussion_r157371967"},"pull_request":{"href":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/12","id":158094170,"html_url":"https://github.com/alyokhina-olya/JavaHW/pull/12","diff_url":"https://github.com/alyokhina-olya/JavaHW/pull/12.diff","patch_url":"https://github.com/alyokhina-olya/JavaHW/pull/12.patch","issue_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/issues/12","number":12,"state":"open","locked":false,"title":"Test2","user":{"login":"alyokhina-olya","id":29375898,"avatar_url":"https://avatars2.githubusercontent.com/u/29375898?v=4","gravatar_id":"","url":"https://api.github.com/users/alyokhina-olya","html_url":"https://github.com/alyokhina-olya","followers_url":"https://api.github.com/users/alyokhina-olya/followers","following_url":"https://api.github.com/users/alyokhina-olya/following{/other_user}","gists_url":"https://api.github.com/users/alyokhina-olya/gists{/gist_id}","starred_url":"https://api.github.com/users/alyokhina-olya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alyokhina-olya/subscriptions","organizations_url":"https://api.github.com/users/alyokhina-olya/orgs","repos_url":"https://api.github.com/users/alyokhina-olya/repos","events_url":"https://api.github.com/users/alyokhina-olya/events{/privacy}","received_events_url":"https://api.github.com/users/alyokhina-olya/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-12-13T13:31:35Z","updated_at":"2017-12-17T15:58:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ce0334d6bb960408323b27aba30db9854fbc2448","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/12/commits","review_comments_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/12/comments","review_comment_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/issues/12/comments","statuses_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/statuses/218c8be19dd5f4303a84b33b4b32b31a7ac155c0","head":{"label":"alyokhina-olya:Test2","ref":"Test2","sha":"218c8be19dd5f4303a84b33b4b32b31a7ac155c0","user":{"login":"alyokhina-olya","id":29375898,"avatar_url":"https://avatars2.githubusercontent.com/u/29375898?v=4","gravatar_id":"","url":"https://api.github.com/users/alyokhina-olya","html_url":"https://github.com/alyokhina-olya","followers_url":"https://api.github.com/users/alyokhina-olya/followers","following_url":"https://api.github.com/users/alyokhina-olya/following{/other_user}","gists_url":"https://api.github.com/users/alyokhina-olya/gists{/gist_id}","starred_url":"https://api.github.com/users/alyokhina-olya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alyokhina-olya/subscriptions","organizations_url":"https://api.github.com/users/alyokhina-olya/orgs","repos_url":"https://api.github.com/users/alyokhina-olya/repos","events_url":"https://api.github.com/users/alyokhina-olya/events{/privacy}","received_events_url":"https://api.github.com/users/alyokhina-olya/received_events","type":"User","site_admin":false},"repo":{"id":103327565,"name":"JavaHW","full_name":"alyokhina-olya/JavaHW","owner":{"login":"alyokhina-olya","id":29375898,"avatar_url":"https://avatars2.githubusercontent.com/u/29375898?v=4","gravatar_id":"","url":"https://api.github.com/users/alyokhina-olya","html_url":"https://github.com/alyokhina-olya","followers_url":"https://api.github.com/users/alyokhina-olya/followers","following_url":"https://api.github.com/users/alyokhina-olya/following{/other_user}","gists_url":"https://api.github.com/users/alyokhina-olya/gists{/gist_id}","starred_url":"https://api.github.com/users/alyokhina-olya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alyokhina-olya/subscriptions","organizations_url":"https://api.github.com/users/alyokhina-olya/orgs","repos_url":"https://api.github.com/users/alyokhina-olya/repos","events_url":"https://api.github.com/users/alyokhina-olya/events{/privacy}","received_events_url":"https://api.github.com/users/alyokhina-olya/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alyokhina-olya/JavaHW","description":null,"fork":false,"url":"https://api.github.com/repos/alyokhina-olya/JavaHW","forks_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/forks","keys_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/teams","hooks_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/hooks","issue_events_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/issues/events{/number}","events_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/events","assignees_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/assignees{/user}","branches_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/branches{/branch}","tags_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/tags","blobs_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/git/refs{/sha}","trees_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/statuses/{sha}","languages_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/languages","stargazers_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/stargazers","contributors_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/contributors","subscribers_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/subscribers","subscription_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/subscription","commits_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/commits{/sha}","git_commits_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/git/commits{/sha}","comments_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/comments{/number}","issue_comment_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/issues/comments{/number}","contents_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/contents/{+path}","compare_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/merges","archive_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/downloads","issues_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/issues{/number}","pulls_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls{/number}","milestones_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/milestones{/number}","notifications_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/labels{/name}","releases_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/releases{/id}","deployments_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/deployments","created_at":"2017-09-12T22:43:57Z","updated_at":"2017-10-16T12:00:20Z","pushed_at":"2017-12-13T13:31:35Z","git_url":"git://github.com/alyokhina-olya/JavaHW.git","ssh_url":"git@github.com:alyokhina-olya/JavaHW.git","clone_url":"https://github.com/alyokhina-olya/JavaHW.git","svn_url":"https://github.com/alyokhina-olya/JavaHW","homepage":null,"size":88,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"alyokhina-olya:master","ref":"master","sha":"29fc17a5b633fa5ef41d9199a55a757b9126608f","user":{"login":"alyokhina-olya","id":29375898,"avatar_url":"https://avatars2.githubusercontent.com/u/29375898?v=4","gravatar_id":"","url":"https://api.github.com/users/alyokhina-olya","html_url":"https://github.com/alyokhina-olya","followers_url":"https://api.github.com/users/alyokhina-olya/followers","following_url":"https://api.github.com/users/alyokhina-olya/following{/other_user}","gists_url":"https://api.github.com/users/alyokhina-olya/gists{/gist_id}","starred_url":"https://api.github.com/users/alyokhina-olya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alyokhina-olya/subscriptions","organizations_url":"https://api.github.com/users/alyokhina-olya/orgs","repos_url":"https://api.github.com/users/alyokhina-olya/repos","events_url":"https://api.github.com/users/alyokhina-olya/events{/privacy}","received_events_url":"https://api.github.com/users/alyokhina-olya/received_events","type":"User","site_admin":false},"repo":{"id":103327565,"name":"JavaHW","full_name":"alyokhina-olya/JavaHW","owner":{"login":"alyokhina-olya","id":29375898,"avatar_url":"https://avatars2.githubusercontent.com/u/29375898?v=4","gravatar_id":"","url":"https://api.github.com/users/alyokhina-olya","html_url":"https://github.com/alyokhina-olya","followers_url":"https://api.github.com/users/alyokhina-olya/followers","following_url":"https://api.github.com/users/alyokhina-olya/following{/other_user}","gists_url":"https://api.github.com/users/alyokhina-olya/gists{/gist_id}","starred_url":"https://api.github.com/users/alyokhina-olya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alyokhina-olya/subscriptions","organizations_url":"https://api.github.com/users/alyokhina-olya/orgs","repos_url":"https://api.github.com/users/alyokhina-olya/repos","events_url":"https://api.github.com/users/alyokhina-olya/events{/privacy}","received_events_url":"https://api.github.com/users/alyokhina-olya/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alyokhina-olya/JavaHW","description":null,"fork":false,"url":"https://api.github.com/repos/alyokhina-olya/JavaHW","forks_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/forks","keys_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/teams","hooks_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/hooks","issue_events_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/issues/events{/number}","events_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/events","assignees_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/assignees{/user}","branches_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/branches{/branch}","tags_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/tags","blobs_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/git/refs{/sha}","trees_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/statuses/{sha}","languages_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/languages","stargazers_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/stargazers","contributors_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/contributors","subscribers_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/subscribers","subscription_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/subscription","commits_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/commits{/sha}","git_commits_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/git/commits{/sha}","comments_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/comments{/number}","issue_comment_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/issues/comments{/number}","contents_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/contents/{+path}","compare_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/merges","archive_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/downloads","issues_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/issues{/number}","pulls_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls{/number}","milestones_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/milestones{/number}","notifications_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/labels{/name}","releases_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/releases{/id}","deployments_url":"https://api.github.com/repos/alyokhina-olya/JavaHW/deployments","created_at":"2017-09-12T22:43:57Z","updated_at":"2017-10-16T12:00:20Z","pushed_at":"2017-12-13T13:31:35Z","git_url":"git://github.com/alyokhina-olya/JavaHW.git","ssh_url":"git@github.com:alyokhina-olya/JavaHW.git","clone_url":"https://github.com/alyokhina-olya/JavaHW.git","svn_url":"https://github.com/alyokhina-olya/JavaHW","homepage":null,"size":88,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/12"},"html":{"href":"https://github.com/alyokhina-olya/JavaHW/pull/12"},"issue":{"href":"https://api.github.com/repos/alyokhina-olya/JavaHW/issues/12"},"comments":{"href":"https://api.github.com/repos/alyokhina-olya/JavaHW/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alyokhina-olya/JavaHW/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/alyokhina-olya/JavaHW/statuses/218c8be19dd5f4303a84b33b4b32b31a7ac155c0"}},"author_association":"OWNER"}}
{"actor":{"display_login":"jzuken"}}