{"action":"created","comment":{"url":"https://api.github.com/repos/XJIE6/JavaHW/pulls/comments/62391091","id":62391091,"diff_hunk":"@@ -0,0 +1,113 @@\n+package sp;\n+\n+import java.util.*;\n+import java.util.stream.Collectors;\n+import java.util.stream.IntStream;\n+import java.util.stream.Stream;\n+\n+public final class FirstPartTasks {\n+\n+    private FirstPartTasks() {}\n+\n+    // Список названий альбомов\n+    public static List<String> allNames(Stream<Album> albums) {\n+        return albums.map(Album::getName).collect(Collectors.toList());\n+    }\n+\n+    // Список названий альбомов, отсортированный лексикографически по названию\n+    public static List<String> allNamesSorted(Stream<Album> albums) {\n+        return albums\n+                .map(Album::getName)\n+                .sorted()\n+                .collect(Collectors.toList());\n+    }\n+\n+    // Список треков, отсортированный лексикографически по названию, включающий все треки альбомов из 'albums'\n+    public static List<String> allTracksSorted(Stream<Album> albums) {\n+        return albums\n+                .map(Album::getTracks)\n+                .flatMap(List::stream)\n+                .map(Track::getName)\n+                .sorted()\n+                .collect(Collectors.toList());\n+    }\n+\n+    // Список альбомов, в которых есть хотя бы один трек с рейтингом более 95, отсортированный по названию\n+    public static List<Album> sortedFavorites(Stream<Album> albums) {\n+        return albums\n+                .filter(album -> album\n+                        .getTracks()\n+                        .stream()\n+                        .filter(track -> track.getRating() > 95)\n+                        .count() > 0)\n+                .sorted(Comparator.comparing(Album::getName))\n+                .collect(Collectors.toList());\n+    }\n+\n+    // Сгруппировать альбомы по артистам\n+    public static Map<Artist, List<Album>> groupByArtist(Stream<Album> albums) {\n+        return albums\n+                .collect(Collectors.groupingBy(Album::getArtist));\n+    }\n+\n+    // Сгруппировать альбомы по артистам (в качестве значения вместо объекта 'Artist' использовать его имя)\n+    public static Map<Artist, List<String>> groupByArtistMapName(Stream<Album> albums) {\n+        return albums\n+                .collect(Collectors.groupingBy(\n+                                Album::getArtist,\n+                                Collectors.mapping(\n+                                        Album::getName,\n+                                        Collectors.toList())));\n+    }\n+\n+    // Число повторяющихся альбомов в потоке\n+    public static long countAlbumDuplicates(Stream<Album> albums) {\n+        return albums\n+                .collect(Collectors.groupingBy(a -> a))\n+                .values()\n+                .stream()\n+                .filter(l -> l.size() > 1)\n+                .count();\n+    }\n+\n+    // Альбом, в котором максимум рейтинга минимален\n+    // (если в альбоме нет ни одного трека, считать, что максимум рейтинга в нем --- 0)\n+    public static Optional<Album> minMaxRating(Stream<Album> albums) {\n+        return albums\n+                .min(Comparator.comparingInt(a -> a\n+                        .getTracks()\n+                        .stream()\n+                        .map(Track::getRating)\n+                        .max(Comparator.naturalOrder())\n+                        .orElse(0)));\n+    }\n+\n+    // Список альбомов, отсортированный по убыванию среднего рейтинга его треков (0, если треков нет)\n+    public static List<Album> sortByAverageRating(Stream<Album> albums) {\n+        return albums\n+                .sorted(Comparator.comparingDouble((Album a) -> a\n+                        .getTracks()\n+                        .stream()\n+                        .mapToInt(Track::getRating)\n+                        .average().orElse(0)).reversed())\n+                .collect(Collectors.toList());\n+    }\n+\n+    // Произведение всех чисел потока по модулю 'modulo'\n+    // (все числа от 0 до 10000)\n+    public static int moduloProduction(IntStream stream, int modulo) {\n+        return stream.reduce(1, (a, b) -> a * b % modulo);\n+    }\n+\n+    // Вернуть строку, состояющую из конкатенаций переданного массива, и окруженную строками \"<\", \">\"\n+    // см. тесты\n+    public static String joinTo(String... strings) {\n+        return Arrays.stream(strings)\n+                .collect(Collectors.joining(\", \", \"<\", \">\"));\n+    }\n+\n+    // Вернуть поток из объектов класса 'clazz'\n+    public static <R> Stream<R> filterIsInstance(Stream<?> s, Class<R> clazz) {\n+        return (Stream<R>) s.filter(o -> clazz.isAssignableFrom(o.getClass()));","path":"src/main/java/sp/FirstPartTasks.java","position":111,"original_position":111,"commit_id":"44e654356f44cdcc3358a3ebffa73749f5ccdb4f","original_commit_id":"44e654356f44cdcc3358a3ebffa73749f5ccdb4f","user":{"login":"sproshev","id":4990763,"avatar_url":"https://avatars.githubusercontent.com/u/4990763?v=3","gravatar_id":"","url":"https://api.github.com/users/sproshev","html_url":"https://github.com/sproshev","followers_url":"https://api.github.com/users/sproshev/followers","following_url":"https://api.github.com/users/sproshev/following{/other_user}","gists_url":"https://api.github.com/users/sproshev/gists{/gist_id}","starred_url":"https://api.github.com/users/sproshev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sproshev/subscriptions","organizations_url":"https://api.github.com/users/sproshev/orgs","repos_url":"https://api.github.com/users/sproshev/repos","events_url":"https://api.github.com/users/sproshev/events{/privacy}","received_events_url":"https://api.github.com/users/sproshev/received_events","type":"User","site_admin":false},"body":"```(Stream<R>) s.filter(clazz::isInstance)```","created_at":"2016-05-06T21:07:01Z","updated_at":"2016-05-06T21:07:01Z","html_url":"https://github.com/XJIE6/JavaHW/pull/4#discussion_r62391091","pull_request_url":"https://api.github.com/repos/XJIE6/JavaHW/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/XJIE6/JavaHW/pulls/comments/62391091"},"html":{"href":"https://github.com/XJIE6/JavaHW/pull/4#discussion_r62391091"},"pull_request":{"href":"https://api.github.com/repos/XJIE6/JavaHW/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/XJIE6/JavaHW/pulls/4","id":68594599,"html_url":"https://github.com/XJIE6/JavaHW/pull/4","diff_url":"https://github.com/XJIE6/JavaHW/pull/4.diff","patch_url":"https://github.com/XJIE6/JavaHW/pull/4.patch","issue_url":"https://api.github.com/repos/XJIE6/JavaHW/issues/4","number":4,"state":"open","locked":false,"title":"Java02. ДЗ 03, Кравченко Юрий, подгруппа 2","user":{"login":"XJIE6","id":10938034,"avatar_url":"https://avatars.githubusercontent.com/u/10938034?v=3","gravatar_id":"","url":"https://api.github.com/users/XJIE6","html_url":"https://github.com/XJIE6","followers_url":"https://api.github.com/users/XJIE6/followers","following_url":"https://api.github.com/users/XJIE6/following{/other_user}","gists_url":"https://api.github.com/users/XJIE6/gists{/gist_id}","starred_url":"https://api.github.com/users/XJIE6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XJIE6/subscriptions","organizations_url":"https://api.github.com/users/XJIE6/orgs","repos_url":"https://api.github.com/users/XJIE6/repos","events_url":"https://api.github.com/users/XJIE6/events{/privacy}","received_events_url":"https://api.github.com/users/XJIE6/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-02T17:54:34Z","updated_at":"2016-05-06T21:07:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b9e62e1725ce8829a7acf1f1a4a5a330342609c1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/XJIE6/JavaHW/pulls/4/commits","review_comments_url":"https://api.github.com/repos/XJIE6/JavaHW/pulls/4/comments","review_comment_url":"https://api.github.com/repos/XJIE6/JavaHW/pulls/comments{/number}","comments_url":"https://api.github.com/repos/XJIE6/JavaHW/issues/4/comments","statuses_url":"https://api.github.com/repos/XJIE6/JavaHW/statuses/44e654356f44cdcc3358a3ebffa73749f5ccdb4f","head":{"label":"XJIE6:hw2","ref":"hw2","sha":"44e654356f44cdcc3358a3ebffa73749f5ccdb4f","user":{"login":"XJIE6","id":10938034,"avatar_url":"https://avatars.githubusercontent.com/u/10938034?v=3","gravatar_id":"","url":"https://api.github.com/users/XJIE6","html_url":"https://github.com/XJIE6","followers_url":"https://api.github.com/users/XJIE6/followers","following_url":"https://api.github.com/users/XJIE6/following{/other_user}","gists_url":"https://api.github.com/users/XJIE6/gists{/gist_id}","starred_url":"https://api.github.com/users/XJIE6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XJIE6/subscriptions","organizations_url":"https://api.github.com/users/XJIE6/orgs","repos_url":"https://api.github.com/users/XJIE6/repos","events_url":"https://api.github.com/users/XJIE6/events{/privacy}","received_events_url":"https://api.github.com/users/XJIE6/received_events","type":"User","site_admin":false},"repo":{"id":51589383,"name":"JavaHW","full_name":"XJIE6/JavaHW","owner":{"login":"XJIE6","id":10938034,"avatar_url":"https://avatars.githubusercontent.com/u/10938034?v=3","gravatar_id":"","url":"https://api.github.com/users/XJIE6","html_url":"https://github.com/XJIE6","followers_url":"https://api.github.com/users/XJIE6/followers","following_url":"https://api.github.com/users/XJIE6/following{/other_user}","gists_url":"https://api.github.com/users/XJIE6/gists{/gist_id}","starred_url":"https://api.github.com/users/XJIE6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XJIE6/subscriptions","organizations_url":"https://api.github.com/users/XJIE6/orgs","repos_url":"https://api.github.com/users/XJIE6/repos","events_url":"https://api.github.com/users/XJIE6/events{/privacy}","received_events_url":"https://api.github.com/users/XJIE6/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/XJIE6/JavaHW","description":"my java hw","fork":false,"url":"https://api.github.com/repos/XJIE6/JavaHW","forks_url":"https://api.github.com/repos/XJIE6/JavaHW/forks","keys_url":"https://api.github.com/repos/XJIE6/JavaHW/keys{/key_id}","collaborators_url":"https://api.github.com/repos/XJIE6/JavaHW/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/XJIE6/JavaHW/teams","hooks_url":"https://api.github.com/repos/XJIE6/JavaHW/hooks","issue_events_url":"https://api.github.com/repos/XJIE6/JavaHW/issues/events{/number}","events_url":"https://api.github.com/repos/XJIE6/JavaHW/events","assignees_url":"https://api.github.com/repos/XJIE6/JavaHW/assignees{/user}","branches_url":"https://api.github.com/repos/XJIE6/JavaHW/branches{/branch}","tags_url":"https://api.github.com/repos/XJIE6/JavaHW/tags","blobs_url":"https://api.github.com/repos/XJIE6/JavaHW/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/XJIE6/JavaHW/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/XJIE6/JavaHW/git/refs{/sha}","trees_url":"https://api.github.com/repos/XJIE6/JavaHW/git/trees{/sha}","statuses_url":"https://api.github.com/repos/XJIE6/JavaHW/statuses/{sha}","languages_url":"https://api.github.com/repos/XJIE6/JavaHW/languages","stargazers_url":"https://api.github.com/repos/XJIE6/JavaHW/stargazers","contributors_url":"https://api.github.com/repos/XJIE6/JavaHW/contributors","subscribers_url":"https://api.github.com/repos/XJIE6/JavaHW/subscribers","subscription_url":"https://api.github.com/repos/XJIE6/JavaHW/subscription","commits_url":"https://api.github.com/repos/XJIE6/JavaHW/commits{/sha}","git_commits_url":"https://api.github.com/repos/XJIE6/JavaHW/git/commits{/sha}","comments_url":"https://api.github.com/repos/XJIE6/JavaHW/comments{/number}","issue_comment_url":"https://api.github.com/repos/XJIE6/JavaHW/issues/comments{/number}","contents_url":"https://api.github.com/repos/XJIE6/JavaHW/contents/{+path}","compare_url":"https://api.github.com/repos/XJIE6/JavaHW/compare/{base}...{head}","merges_url":"https://api.github.com/repos/XJIE6/JavaHW/merges","archive_url":"https://api.github.com/repos/XJIE6/JavaHW/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/XJIE6/JavaHW/downloads","issues_url":"https://api.github.com/repos/XJIE6/JavaHW/issues{/number}","pulls_url":"https://api.github.com/repos/XJIE6/JavaHW/pulls{/number}","milestones_url":"https://api.github.com/repos/XJIE6/JavaHW/milestones{/number}","notifications_url":"https://api.github.com/repos/XJIE6/JavaHW/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/XJIE6/JavaHW/labels{/name}","releases_url":"https://api.github.com/repos/XJIE6/JavaHW/releases{/id}","deployments_url":"https://api.github.com/repos/XJIE6/JavaHW/deployments","created_at":"2016-02-12T13:34:20Z","updated_at":"2016-02-12T13:34:20Z","pushed_at":"2016-05-02T18:09:41Z","git_url":"git://github.com/XJIE6/JavaHW.git","ssh_url":"git@github.com:XJIE6/JavaHW.git","clone_url":"https://github.com/XJIE6/JavaHW.git","svn_url":"https://github.com/XJIE6/JavaHW","homepage":null,"size":1727,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"XJIE6:master","ref":"master","sha":"1a2a3665751ef1213fa547644942ec6166e8182b","user":{"login":"XJIE6","id":10938034,"avatar_url":"https://avatars.githubusercontent.com/u/10938034?v=3","gravatar_id":"","url":"https://api.github.com/users/XJIE6","html_url":"https://github.com/XJIE6","followers_url":"https://api.github.com/users/XJIE6/followers","following_url":"https://api.github.com/users/XJIE6/following{/other_user}","gists_url":"https://api.github.com/users/XJIE6/gists{/gist_id}","starred_url":"https://api.github.com/users/XJIE6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XJIE6/subscriptions","organizations_url":"https://api.github.com/users/XJIE6/orgs","repos_url":"https://api.github.com/users/XJIE6/repos","events_url":"https://api.github.com/users/XJIE6/events{/privacy}","received_events_url":"https://api.github.com/users/XJIE6/received_events","type":"User","site_admin":false},"repo":{"id":51589383,"name":"JavaHW","full_name":"XJIE6/JavaHW","owner":{"login":"XJIE6","id":10938034,"avatar_url":"https://avatars.githubusercontent.com/u/10938034?v=3","gravatar_id":"","url":"https://api.github.com/users/XJIE6","html_url":"https://github.com/XJIE6","followers_url":"https://api.github.com/users/XJIE6/followers","following_url":"https://api.github.com/users/XJIE6/following{/other_user}","gists_url":"https://api.github.com/users/XJIE6/gists{/gist_id}","starred_url":"https://api.github.com/users/XJIE6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XJIE6/subscriptions","organizations_url":"https://api.github.com/users/XJIE6/orgs","repos_url":"https://api.github.com/users/XJIE6/repos","events_url":"https://api.github.com/users/XJIE6/events{/privacy}","received_events_url":"https://api.github.com/users/XJIE6/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/XJIE6/JavaHW","description":"my java hw","fork":false,"url":"https://api.github.com/repos/XJIE6/JavaHW","forks_url":"https://api.github.com/repos/XJIE6/JavaHW/forks","keys_url":"https://api.github.com/repos/XJIE6/JavaHW/keys{/key_id}","collaborators_url":"https://api.github.com/repos/XJIE6/JavaHW/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/XJIE6/JavaHW/teams","hooks_url":"https://api.github.com/repos/XJIE6/JavaHW/hooks","issue_events_url":"https://api.github.com/repos/XJIE6/JavaHW/issues/events{/number}","events_url":"https://api.github.com/repos/XJIE6/JavaHW/events","assignees_url":"https://api.github.com/repos/XJIE6/JavaHW/assignees{/user}","branches_url":"https://api.github.com/repos/XJIE6/JavaHW/branches{/branch}","tags_url":"https://api.github.com/repos/XJIE6/JavaHW/tags","blobs_url":"https://api.github.com/repos/XJIE6/JavaHW/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/XJIE6/JavaHW/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/XJIE6/JavaHW/git/refs{/sha}","trees_url":"https://api.github.com/repos/XJIE6/JavaHW/git/trees{/sha}","statuses_url":"https://api.github.com/repos/XJIE6/JavaHW/statuses/{sha}","languages_url":"https://api.github.com/repos/XJIE6/JavaHW/languages","stargazers_url":"https://api.github.com/repos/XJIE6/JavaHW/stargazers","contributors_url":"https://api.github.com/repos/XJIE6/JavaHW/contributors","subscribers_url":"https://api.github.com/repos/XJIE6/JavaHW/subscribers","subscription_url":"https://api.github.com/repos/XJIE6/JavaHW/subscription","commits_url":"https://api.github.com/repos/XJIE6/JavaHW/commits{/sha}","git_commits_url":"https://api.github.com/repos/XJIE6/JavaHW/git/commits{/sha}","comments_url":"https://api.github.com/repos/XJIE6/JavaHW/comments{/number}","issue_comment_url":"https://api.github.com/repos/XJIE6/JavaHW/issues/comments{/number}","contents_url":"https://api.github.com/repos/XJIE6/JavaHW/contents/{+path}","compare_url":"https://api.github.com/repos/XJIE6/JavaHW/compare/{base}...{head}","merges_url":"https://api.github.com/repos/XJIE6/JavaHW/merges","archive_url":"https://api.github.com/repos/XJIE6/JavaHW/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/XJIE6/JavaHW/downloads","issues_url":"https://api.github.com/repos/XJIE6/JavaHW/issues{/number}","pulls_url":"https://api.github.com/repos/XJIE6/JavaHW/pulls{/number}","milestones_url":"https://api.github.com/repos/XJIE6/JavaHW/milestones{/number}","notifications_url":"https://api.github.com/repos/XJIE6/JavaHW/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/XJIE6/JavaHW/labels{/name}","releases_url":"https://api.github.com/repos/XJIE6/JavaHW/releases{/id}","deployments_url":"https://api.github.com/repos/XJIE6/JavaHW/deployments","created_at":"2016-02-12T13:34:20Z","updated_at":"2016-02-12T13:34:20Z","pushed_at":"2016-05-02T18:09:41Z","git_url":"git://github.com/XJIE6/JavaHW.git","ssh_url":"git@github.com:XJIE6/JavaHW.git","clone_url":"https://github.com/XJIE6/JavaHW.git","svn_url":"https://github.com/XJIE6/JavaHW","homepage":null,"size":1727,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/XJIE6/JavaHW/pulls/4"},"html":{"href":"https://github.com/XJIE6/JavaHW/pull/4"},"issue":{"href":"https://api.github.com/repos/XJIE6/JavaHW/issues/4"},"comments":{"href":"https://api.github.com/repos/XJIE6/JavaHW/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/XJIE6/JavaHW/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/XJIE6/JavaHW/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/XJIE6/JavaHW/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/XJIE6/JavaHW/statuses/44e654356f44cdcc3358a3ebffa73749f5ccdb4f"}}}}