﻿{"id":2295,"date":"2017-02-18T21:48:29","date_gmt":"2017-02-18T12:48:29","guid":{"rendered":"http:\/\/yucchi.jp\/blog\/?p=2295"},"modified":"2017-02-18T21:49:32","modified_gmt":"2017-02-18T12:49:32","slug":"java-se-9-%e3%81%ae%e4%ba%88%e7%bf%92","status":"publish","type":"post","link":"http:\/\/yucchi.jp\/blog\/?p=2295","title":{"rendered":"Java SE 9 \u306e\u4e88\u7fd2"},"content":{"rendered":"<p>\u4eca\u65e5\u306f\u79c1\u306e\u25cb\uff38\u56de\u76ee\u306e\u8a95\u751f\u65e5\u3067\u3059\u3002<\/p>\n<p>\u4eca\u5e74\u306f\u5fd8\u308c\u3089\u308c\u305a\u306b\u304a\u795d\u3044\u306e\u30d7\u30ec\u30bc\u30f3\u30c8\u307e\u3067\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002(^_^)<\/p>\n<p>\u3044\u304f\u3064\u306b\u306a\u3063\u3066\u3082\u8a95\u751f\u65e5\u3092\u795d\u3063\u3066\u3082\u3089\u3048\u308b\u306e\u306f\u5b09\u3057\u3044\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u3068\u8a00\u3046\u308f\u3051\u3067\u304a\u8a95\u751f\u65e5\u8a18\u5ff5\u3068\u3057\u3066\u4eca\u5e74\u306e\u590f\u306b\u30ea\u30ea\u30fc\u30b9\u4e88\u5b9a\u306e Java SE 9 \u306e\u4e88\u7fd2\u3092\u306f\u3058\u3081\u307e\u3059\u3002<\/p>\n<p>Java SE 9 \u3068\u8a00\u3048\u3070 Project Jigsaw, Project Kulla (JShell) \u304c\u76ee\u7389\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306f\u3053\u308c\u304b\u3089\u65e5\u672c\u8a9e\u3067\u306e\u60c5\u5831\u3082\u305f\u304f\u3055\u3093\u51fa\u3066\u304f\u308b\u3068\u601d\u3046\u306e\u3067\u5f8c\u56de\u3057\u3068\u3057\u307e\u3059\u3002(\u65e2\u306b<a href=\"http:\/\/itpro.nikkeibp.co.jp\/atcl\/column\/15\/120700278\/?TOC=1&amp;ST=upper&amp;rt=nocnt\" target=\"_blank\">\u6700\u65b0Java\u60c5\u5831\u5c40<\/a>\u3067\u8a18\u4e8b\u304c\u3042\u308a\u307e\u3059\u3002)<\/p>\n<p>\u6545\u306b Java SE 9 \u3092\u4f7f\u3046\u306e\u3067\u3042\u308c\u3070\u5fc5\u8981\u6700\u4f4e\u9650\u3053\u308c\u3060\u3051\u306f\u899a\u3048\u3066\u304a\u304d\u305f\u3044\u3053\u3068\u3092\u81ea\u5206\u7528\u30e1\u30e2\u3068\u3057\u3066\u8f09\u305b\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p><strong><font color=\"#ff0000\" size=\"4\">\u5b8c\u5168\u306b\u81ea\u5206\u7528\u306e\u30e1\u30e2\u3067\u3059\uff01<\/font><\/strong><\/p>\n<pre title=\"MyFriends.java\">package jp.yucchi.jdk9eaexample;\r\n\r\nimport java.time.LocalDate;\r\nimport java.time.Period;\r\nimport java.util.List;\r\n\r\n\/**\r\n *\r\n * @author Yucchi\r\n *\/\r\nclass MyFriends {\r\n\r\n    public enum Sex {\r\n        MALE, FEMALE, OKAMA\r\n    }\r\n\r\n    int id;\r\n    String name;\r\n    LocalDate birthday;\r\n    Sex gender;\r\n    String phoneNumber;\r\n    String profession;\r\n    String birthplace;\r\n    int favorabilityRating;\r\n    List&lt;String&gt; hobby;\r\n\r\n    MyFriends(int id, String name, LocalDate birthday, Sex gender, String phoneNumber, String profession, String birthplace, int favorabilityRating, List&lt;String&gt; hobby) {\r\n        this.id = id;\r\n        this.name = name;\r\n        this.birthday = birthday;\r\n        this.gender = gender;\r\n        this.phoneNumber = phoneNumber;\r\n        this.profession = profession;\r\n        this.birthplace = birthplace;\r\n        this.favorabilityRating = favorabilityRating;\r\n        this.hobby = hobby;\r\n    }\r\n\r\n    public int getId() {\r\n        return id;\r\n    }\r\n\r\n    public String getName() {\r\n        return name;\r\n    }\r\n\r\n    public LocalDate getBirthday() {\r\n        return birthday;\r\n    }\r\n\r\n    public Sex getGender() {\r\n        return gender;\r\n    }\r\n\r\n    public String getPhoneNumber() {\r\n        return phoneNumber;\r\n    }\r\n\r\n    public String getProfession() {\r\n        return profession;\r\n    }\r\n\r\n    public String getBirthplace() {\r\n        return birthplace;\r\n    }\r\n\r\n    public int getFavorabilityRating() {\r\n        return favorabilityRating;\r\n    }\r\n\r\n    public int getAge() {\r\n        return Period.between(birthday, LocalDate.now()).getYears();\r\n    }\r\n\r\n    public List&lt;String&gt; getHobby() {\r\n        return hobby;\r\n    }\r\n\r\n    public void printMyFriends() {\r\n        System.out.println(this.id + \": \" + this.name + \", \" + this.getAge() + \"\u6b73\" + \", Gender: \"\r\n                + this.gender + \", \u96fb\u8a71\u756a\u53f7: \" + this.phoneNumber\r\n                + \", \u8077\u696d: \" + this.profession + \", \u51fa\u8eab\u5730: \" + this.birthplace\r\n                + \", \u597d\u611f\u5ea6: \" + this.favorabilityRating + \", \u8da3\u5473: \" + this.hobby);\r\n    }\r\n\r\n}\r\n\r\n<\/pre>\n<pre title=\"JDK9eaExample.java\" mark=\"27,81,98,166,228,229,230,244,304,326,335,343,344,350\">package jp.yucchi.jdk9eaexample;\r\n\r\nimport java.time.LocalDate;\r\nimport java.util.ArrayList;\r\nimport java.util.Comparator;\r\nimport java.util.List;\r\nimport java.util.Map;\r\nimport java.util.Objects;\r\nimport java.util.Optional;\r\nimport java.util.Set;\r\nimport java.util.function.Function;\r\nimport java.util.stream.Collectors;\r\nimport java.util.stream.IntStream;\r\nimport java.util.stream.Stream;\r\n\r\n\/**\r\n *\r\n * @author Yucchi\r\n *\/\r\npublic class JDK9eaExample {\r\n\r\n    public static void main(String[] args) {\r\n\r\n        List&lt;MyFriends&gt; myFriends = new ArrayList&lt;&gt;();\r\n\r\n        myFriends.add(new MyFriends(1, \"\u67f4\u7530 \u606d\u5e73\", LocalDate.of(1951, 8, 18), MyFriends.Sex.MALE, \"81300000001\", \"\u4ff3\u512a\", \"\u9759\u5ca1\u770c\", 80,\r\n                List.of(\"\u91ce\u7403\", \"\u30b5\u30c3\u30ab\u30fc\", \"\u4e09\u5473\u7dda\")));\r\n        myFriends.add(new MyFriends(2, \"\u5c0f\u6817 \u65ec\", LocalDate.of(1982, 12, 26), MyFriends.Sex.MALE, \"81300000002\", \"\u4ff3\u512a\", \"\u6771\u4eac\u90fd\", 75,\r\n                List.of(\"\u91ce\u7403\", \"\u97f3\u697d\u9451\u8cde\", \"\u30d5\u30a3\u30ae\u30a2\u53ce\u96c6\", \"\u30de\u30f3\u30ac\")));\r\n        myFriends.add(new MyFriends(3, \"\u5e02\u539f \u96bc\u4eba\", LocalDate.of(1987, 2, 6), MyFriends.Sex.MALE, \"81300000003\", \"\u4ff3\u512a\", \"\u795e\u5948\u5ddd\u770c\", 70,\r\n                List.of(\"\u30c6\u30ec\u30d3\u30b2\u30fc\u30e0\", \"\u30ab\u30e9\u30aa\u30b1\")));\r\n        myFriends.add(new MyFriends(4, \"\u5b89\u500d \u664b\u4e09\", LocalDate.of(1954, 9, 21), MyFriends.Sex.MALE, \"81300000004\", \"\u653f\u6cbb\u5bb6\", \"\u6771\u4eac\u90fd\", 40,\r\n                List.of(\"\u30b4\u30eb\u30d5\", \"\u6620\u753b\u89b3\u8cde\", \"\u8aad\u66f8\", \"\u6c34\u6cf3\")));\r\n        myFriends.add(new MyFriends(5, \"\u30c9\u30ca\u30eb\u30c9 \u30c8\u30e9\u30f3\u30d7\", LocalDate.of(1946, 1, 20), MyFriends.Sex.MALE, \"1100000005\", \"\u653f\u6cbb\u5bb6\", \"\u30cb\u30e5\u30fc\u30e8\u30fc\u30af\", 55,\r\n                List.of(\"\u30b4\u30eb\u30d5\", \"\u30d7\u30ed\u30ec\u30b9\u89b3\u6226\")));\r\n        myFriends.add(new MyFriends(6, \"\u6850\u8c37 \u7f8e\u73b2\", LocalDate.of(1989, 12, 16), MyFriends.Sex.FEMALE, \"81300000006\", \"\u5973\u512a\", \"\u5343\u8449\u770c\", 95,\r\n                List.of(\"\u97f3\u697d\u9451\u8cde\", \"\u30b5\u30c3\u30ab\u30fc\u89b3\u6226\")));\r\n        myFriends.add(new MyFriends(7, \"\u6709\u6751 \u67b6\u7d14\", LocalDate.of(1993, 2, 13), MyFriends.Sex.FEMALE, \"81300000007\", \"\u5973\u512a\", \"\u5175\u5eab\u770c\", 90,\r\n                List.of(\"\u304a\u83d3\u5b50\u3065\u304f\u308a\", \"\u6563\u6b69\", \"\u8cb7\u3044\u7269\")));\r\n        myFriends.add(new MyFriends(8, \"\u7dbe\u702c \u306f\u308b\u304b\", LocalDate.of(1985, 3, 24), MyFriends.Sex.FEMALE, \"81300000008\", \"\u5973\u512a\", \"\u5e83\u5cf6\u770c\", 85,\r\n                List.of(\"\u30ab\u30e9\u30aa\u30b1\", \"\u304a\u83d3\u5b50\u3065\u304f\u308a\", \"\u8db3\u9996\u56de\u3057\")));\r\n        myFriends.add(new MyFriends(9, \"\u4f50\u3005\u6728 \u5e0c\", LocalDate.of(1988, 2, 8), MyFriends.Sex.FEMALE, \"81300000009\", \"\u5973\u512a\", \"\u79cb\u7530\u770c\", 81,\r\n                List.of(\"\u30a2\u30af\u30bb\u30b5\u30ea\u30fc\u53ce\u96c6\")));\r\n        myFriends.add(new MyFriends(10, \"\u525b\u529b \u5f69\u82bd\", LocalDate.of(1992, 8, 27), MyFriends.Sex.FEMALE, \"81300000010\", \"\u5973\u512a\", \"\u795e\u5948\u5ddd\u770c\", 76,\r\n                List.of(\"\u304a\u83d3\u5b50\u3065\u304f\u308a\", \"\u30d5\u30eb\u30fc\u30c8\", \"\u6599\u7406\")));\r\n        myFriends.add(new MyFriends(11, \"\u5800\u5317 \u771f\u5e0c\", LocalDate.of(1988, 10, 6), MyFriends.Sex.FEMALE, \"81300000011\", \"\u5973\u512a\", \"\u6771\u4eac\u90fd\", 88,\r\n                List.of(\"\u8aad\u66f8\", \"\u30b5\u30a4\u30af\u30ea\u30f3\u30b0\")));\r\n        myFriends.add(new MyFriends(12, \"\u6df1\u7530 \u606d\u5b50\", LocalDate.of(1982, 11, 2), MyFriends.Sex.FEMALE, \"81300000012\", \"\u5973\u512a\", \"\u6771\u4eac\u90fd\", 80,\r\n                List.of(\"\u30b5\u30fc\u30d5\u30a3\u30f3\", \"\u66f8\u9053\", \"\u30d4\u30a2\u30ce\", \"\u6c34\u6cf3\")));\r\n        myFriends.add(new MyFriends(13, \"\u5c0f\u6c60 \u767e\u5408\u5b50\", LocalDate.of(1952, 7, 15), MyFriends.Sex.FEMALE, \"81300000013\", \"\u653f\u6cbb\u5bb6\", \"\u5175\u5eab\u770c\", 50,\r\n                List.of(\"\u30b4\u30eb\u30d5\", \"\u30c6\u30cb\u30b9\")));\r\n        myFriends.add(new MyFriends(14, \"\u5b87\u591a\u7530 \u30d2\u30ab\u30eb\", LocalDate.of(1983, 1, 19), MyFriends.Sex.FEMALE, \"81300000014\", \"\u6b4c\u624b\", \"\u30cb\u30e5\u30fc\u30e8\u30fc\u30af\", 91,\r\n                List.of(\"\u8aad\u66f8\", \"\u30de\u30f3\u30ac\", \"\u7d75\u753b\")));\r\n        myFriends.add(new MyFriends(15, \"\u897f\u91ce \u30ab\u30ca\", LocalDate.of(1989, 3, 18), MyFriends.Sex.FEMALE, \"81300000015\", \"\u6b4c\u624b\", \"\u4e09\u91cd\u770c\", 77,\r\n                List.of(\"\u6599\u7406\", \"\u6d77\u5916\u65c5\u884c\")));\r\n        myFriends.add(new MyFriends(16, \"\u304d\u3083\u308a\u30fc\u3071\u307f\u3085\u3071\u307f\u3085\", LocalDate.of(1993, 1, 29), MyFriends.Sex.FEMALE, \"81300000016\", \"\u6b4c\u624b\", \"\u6771\u4eac\u90fd\", 74,\r\n                List.of(\"\u91e3\u308a\", \"\u97f3\u697d\")));\r\n        myFriends.add(new MyFriends(17, \"\u306f\u308b\u306a \u611b\", LocalDate.of(1972, 7, 21), MyFriends.Sex.OKAMA, \"81300000017\", \"\u304a\u30cd\u30a8\u7cfb\u30bf\u30ec\u30f3\u30c8\", \"\u5927\u962a\u5e9c\", 69,\r\n                List.of(\"\u91e3\u308a\", \"\u30b5\u30fc\u30d5\u30a3\u30f3\", \"\u30b9\u30ce\u30fc\u30dc\u30fc\u30c9\", \"\u30b4\u30eb\u30d5\", \"\u6620\u753b\u9451\u8cde\")));\r\n        myFriends.add(new MyFriends(18, \"\u30de\u30c4\u30b3\u30fb\u30c7\u30e9\u30c3\u30af\u30b9\", LocalDate.of(1972, 10, 26), MyFriends.Sex.OKAMA, \"81300000018\", \"\u304a\u30cd\u30a8\u7cfb\u30bf\u30ec\u30f3\u30c8\", \"\u5343\u8449\u770c\", 88,\r\n                List.of(\"\u5973\u88c5\", \"\u30c9\u30e9\u30a4\u30d6\")));\r\n\r\n        \/\/ MyFriends \u5168\u54e1\u8868\u793a\r\n        System.out.println(\"&lt;-- MyFriends --&gt;\");\r\n        myFriends.stream().forEach(MyFriends::printMyFriends);\r\n\r\n        \/\/ Optional::stream\r\n        Function&lt;MyFriends, Optional&lt;MyFriends&gt;&gt; optionalStreamMapper = mf -&gt; mf.getFavorabilityRating() &gt;= 80 ? Optional.of(mf) : Optional.empty();\r\n\r\n        System.out.println(\"\\nJava8 Optional::stream\");\r\n        myFriends.stream()\r\n                .map(optionalStreamMapper)\r\n                .filter(Optional::isPresent)\r\n                .map(Optional::get)\r\n                .collect(Collectors.toList())\r\n                .forEach(MyFriends::printMyFriends);\r\n\r\n        System.out.println(\"\\nJava9 Optional::stream\");\r\n        myFriends.stream()\r\n                .map(optionalStreamMapper)\r\n                .flatMap(Optional::stream)\r\n                .collect(Collectors.toList())\r\n                .forEach(MyFriends::printMyFriends);\r\n\r\n        \/\/ Stream ofNullable\r\n        Function&lt;MyFriends, MyFriends&gt; streamOfNullableMapper = mf -&gt; mf.getAge() &lt; 25 ? mf : null;\r\n\r\n        System.out.println(\"\\nJava8 Stream ofNullable\");\r\n        myFriends.stream()\r\n                .map(streamOfNullableMapper)\r\n                .flatMap(s -&gt; s != null ? Stream.of(s) : Stream.empty())\r\n                .collect(Collectors.toList())\r\n                .forEach(MyFriends::printMyFriends);\r\n\r\n        System.out.println(\"\\nJava9 Stream ofNullable\");\r\n        myFriends.stream()\r\n                .map(streamOfNullableMapper)\r\n                .flatMap(mf -&gt; Stream.ofNullable(mf))\r\n                .collect(Collectors.toList())\r\n                .forEach(MyFriends::printMyFriends);\r\n\r\n        System.out.println(\"\\nID \u3067\u53cb\u9054\u3092\u691c\u7d22\");\r\n        \/\/ ID \u3067\u53cb\u9054\u3092\u691c\u7d22\r\n        findById(7, myFriends);\r\n        \/\/ \u7121\u52b9\u306a ID \u3067\u53cb\u9054\u3092\u691c\u7d22\r\n        findById(27, myFriends);\r\n\r\n        System.out.println(\"\\n\u540d\u524d\u3067\u53cb\u9054\u3092\u691c\u7d22\");\r\n        \/\/ \u540d\u524d\u3067\u53cb\u9054\u3092\u691c\u7d22\r\n        findByName(\"\u6850\u8c37 \u7f8e\u73b2\", myFriends);\r\n        \/\/ \u7121\u52b9\u306a\u540d\u524d\u3067\u53cb\u9054\u3092\u691c\u7d22\r\n        findByName(\"\u4e8c\u968e\u5802 \u3075\u307f\", myFriends);\r\n\r\n        System.out.println(\"\\n\u96fb\u8a71\u756a\u53f7\u3067\u53cb\u9054\u3092\u691c\u7d22\");\r\n        \/\/ \u96fb\u8a71\u756a\u53f7\u3067\u53cb\u9054\u3092\u691c\u7d22\r\n        findByPhoneNumber(\"1100000005\", myFriends);\r\n        \/\/ \u7121\u52b9\u306a\u96fb\u8a71\u756a\u53f7\u3067\u53cb\u9054\u3092\u691c\u7d22\r\n        findByPhoneNumber(\"81300003015\", myFriends);\r\n\r\n        System.out.println(\"\\nID\u3001\u540d\u524d\u3001\u96fb\u8a71\u756a\u53f7\u306e\u9806\u306b\u53cb\u9054\u3092\u691c\u7d22\");\r\n        \/\/ ID\u3001\u540d\u524d\u3001\u96fb\u8a71\u756a\u53f7\u306e\u9806\u306b\u53cb\u9054\u3092\u691c\u7d22\r\n        \/\/ ID\u3001\u540d\u524d\u3001\u96fb\u8a71\u756a\u53f7 \u3059\u3079\u3066\u6709\u52b9 &lt;14: \u5b87\u591a\u7530 \u30d2\u30ab\u30eb, 34\u6b73, Gender: FEMALE, \u96fb\u8a71\u756a\u53f7: 81300000014, \u8077\u696d: \u6b4c\u624b, \u51fa\u8eab\u5730: \u30cb\u30e5\u30fc\u30e8\u30fc\u30af, \u597d\u611f\u5ea6: 911, \u8da3\u5473: [\u8aad\u66f8, \u30de\u30f3\u30ac, \u7d75\u753b]&gt;\r\n        findByMyFriendsIdOrNameOrPhoneNumber(14, \"\u897f\u91ce \u30ab\u30ca\", \"81300000016\", myFriends);\r\n        \/\/ \u540d\u524d\u3001\u96fb\u8a71\u756a\u53f7 \u6709\u52b9 &lt;15: \u897f\u91ce \u30ab\u30ca, 27\u6b73, Gender: FEMALE, \u96fb\u8a71\u756a\u53f7: 81300000015, \u8077\u696d: \u6b4c\u624b, \u51fa\u8eab\u5730: \u4e09\u91cd\u770c, \u597d\u611f\u5ea6: 77, \u8da3\u5473: [\u6599\u7406, \u6d77\u5916\u65c5\u884c]&gt;\r\n        findByMyFriendsIdOrNameOrPhoneNumber(99, \"\u897f\u91ce \u30ab\u30ca\", \"81300000016\", myFriends);\r\n        \/\/ \u96fb\u8a71\u756a\u53f7 \u6709\u52b9 &lt;16: \u304d\u3083\u308a\u30fc\u3071\u307f\u3085\u3071\u307f\u3085, 24\u6b73, Gender: FEMALE, \u96fb\u8a71\u756a\u53f7: 81300000016, \u8077\u696d: \u6b4c\u624b, \u51fa\u8eab\u5730: \u6771\u4eac\u90fd, \u597d\u611f\u5ea6: 74, \u8da3\u5473: [\u91e3\u308a, \u97f3\u697d]&gt;\r\n        findByMyFriendsIdOrNameOrPhoneNumber(99, \"\u4e8c\u968e\u5802 \u3075\u307f\", \"81300000016\", myFriends);\r\n        \/\/ ID\u3001\u540d\u524d\u3001\u96fb\u8a71\u756a\u53f7 \u3059\u3079\u3066\u7121\u52b9\r\n        findByMyFriendsIdOrNameOrPhoneNumber(99, \"\u4e8c\u968e\u5802 \u3075\u307f\", \"81300009014\", myFriends);\r\n\r\n        System.out.println(\"\\n\u8077\u696d\u5225\u306b\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u597d\u611f\u5ea6 90 \u4ee5\u4e0a\u306e\u53cb\u9054\u3092\u691c\u7d22\");\r\n        findByProfession(myFriends, 90);\r\n\r\n        System.out.println(\"\\n\u51fa\u8eab\u5730\u5225\u306b\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u53cb\u9054\u306e\u540d\u524d\u3092\u691c\u7d22\");\r\n        findByBirthplace(myFriends);\r\n\r\n        System.out.println(\"\\n\u8077\u696d\u5225\u306b\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u8da3\u5473\u3092\u691c\u7d22\");\r\n        findByHobbyByProfession(myFriends);\r\n\r\n        System.out.println(\"\\n\u5e74\u9f62\u304c\u82e5\u3044\u9806\u306b\u53cb\u9054\u3092\u8868\u793a\");\r\n        findByYoungOrder(myFriends);\r\n\r\n        System.out.println(\"\\n\u5e74\u9f62\u304c\u82e5\u3044\u9806\u306b\u597d\u611f\u5ea6\u304c70\u672a\u6e80\u306e\u53cb\u9054\u304c\u30d2\u30c3\u30c8\u3059\u308b\u307e\u3067\u691c\u7d22\");\r\n        findByYoungFriendsByFavorabilityRating(myFriends, 70);\r\n\r\n        System.out.println(\"\\n\u5e74\u9f62\u304c\u5927\u304d\u3044\u9806\u306b\u597d\u611f\u5ea6\u304c90\u672a\u6e80\u306e\u53cb\u9054\u304c\u30d2\u30c3\u30c8\u3059\u308b\u307e\u3067\u30b9\u30ad\u30c3\u30d7\u3057\u3066\u691c\u7d22\");\r\n        findByOldFriendsByFavorabilityRating(myFriends, 90);\r\n\r\n        System.out.println(\"\\n\u6761\u4ef6\u4ed8\u304d\u3067\u5e74\u9f62\u304c\u82e5\u3044\u9806\u306b\u53cb\u9054\u3092\u8868\u793a 27\u6b73\u4ee5\u4e0b\u30b9\u30ad\u30c3\u30d7\u300134\u6b73\u307e\u3067 \u30ea\u30df\u30c3\u30c8\");\r\n        findByConditionalYoungOrder(myFriends, 27, 34);\r\n\r\n        System.out.println(\"\\nID 1 \u304b\u3089 Double Calculation \u3067\u8a08\u7b97\u3057\u3066\u53cb\u9054\u3092\u691c\u7d22  \u305f\u3060\u3057\u3001ID \u306f 50 \u672a\u6e80\u306e\u7bc4\u56f2\u3068\u3059\u308b\u3002\uff08\u5b9f\u8cea 32 \u307e\u3067\uff09\");\r\n        findByIdDoubleCalculation(myFriends, 50);\r\n\r\n    }\r\n\r\n    \/\/ ID \u3067\u53cb\u9054\u3092\u691c\u7d22\u3057\u3066\u8868\u793a\u3059\u308b\r\n    private static void findById(int id, List&lt;MyFriends&gt; myFriends) {\r\n        Optional&lt;MyFriends&gt; myFriendsById = findMyFriendsById(id, myFriends);\r\n\/\/        \/\/ Java8  * myFriendsById.ifPresent(MyFriends::printMyFriends); \u3060\u3068\u5b58\u5728\u3057\u306a\u304b\u3063\u305f\u3068\u304d\u306e\u51e6\u7406\u304c\u3067\u304d\u306a\u304f\u3066\u4e0d\u4fbf (&gt;_&lt;)\r\n\/\/        if (myFriendsById.isPresent()) { \/\/ \u3053\u3053\u3067\u65e2\u306b\u8ca0\u3051\u3066\u3044\u308b(&gt;_&lt;)\r\n\/\/            myFriendsById.get().printMyFriends();\r\n\/\/        } else {\r\n\/\/            notFoundById(id);\r\n\/\/        }\r\n        myFriendsById.ifPresentOrElse(MyFriends::printMyFriends, () -&gt; notFoundById(id));\r\n\r\n    }\r\n\r\n    \/\/ ID \u3067\u53cb\u9054\u3092\u691c\u7d22 Optional&lt;MyFriends&gt; \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u53d6\u5f97\r\n    private static Optional&lt;MyFriends&gt; findMyFriendsById(int id, List&lt;MyFriends&gt; myFriends) {\r\n        return myFriends\r\n                .stream()\r\n                .filter(e -&gt; e.getId() == id)\r\n                .findFirst();\r\n    }\r\n\r\n    \/\/ ID \u3067\u53cb\u9054\u3092\u691c\u7d22\u3057\u3066\u5b58\u5728\u3057\u306a\u304b\u3063\u305f\u5834\u5408\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\r\n    private static void notFoundById(int id) {\r\n        System.out.println(\"ID \" + id + \" \u306e\u53cb\u9054\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\");\r\n    }\r\n\r\n    \/\/ \u540d\u524d\u3067\u53cb\u9054\u3092\u691c\u7d22\u3057\u3066\u8868\u793a\u3059\u308b\r\n    private static void findByName(String name, List&lt;MyFriends&gt; myFriends) {\r\n        Optional&lt;MyFriends&gt; myFriendsByName = findMyFriendsByName(name, myFriends);\r\n        myFriendsByName.ifPresentOrElse(MyFriends::printMyFriends, () -&gt; notFoundByName(name));\r\n    }\r\n\r\n    \/\/ \u540d\u524d\u3067\u53cb\u9054\u3092\u691c\u7d22 Optional&lt;MyFriends&gt; \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u53d6\u5f97\r\n    private static Optional&lt;MyFriends&gt; findMyFriendsByName(String name, List&lt;MyFriends&gt; myFriends) {\r\n        return myFriends\r\n                .stream()\r\n                .filter(e -&gt; Objects.equals(e.getName(), name))\r\n                .findFirst();\r\n    }\r\n\r\n    \/\/ \u540d\u524d\u3067\u53cb\u9054\u3092\u691c\u7d22\u3057\u3066\u5b58\u5728\u3057\u306a\u304b\u3063\u305f\u5834\u5408\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\r\n    private static void notFoundByName(String name) {\r\n        System.out.println(\"\u540d\u524d \" + name + \" \u306e\u53cb\u9054\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\");\r\n    }\r\n\r\n    \/\/ \u96fb\u8a71\u756a\u53f7\u3067\u53cb\u9054\u3092\u691c\u7d22\u3057\u3066\u8868\u793a\u3059\u308b\r\n    private static void findByPhoneNumber(String phoneNumber, List&lt;MyFriends&gt; myFriends) {\r\n        Optional&lt;MyFriends&gt; myFriendsByPhoneNumber = findMyFriendsByPhoneNumber(phoneNumber, myFriends);\r\n        myFriendsByPhoneNumber.ifPresentOrElse(MyFriends::printMyFriends, () -&gt; notFoundByPhoneNumber(phoneNumber));\r\n\r\n    }\r\n\r\n    \/\/ \u96fb\u8a71\u756a\u53f7\u3067\u53cb\u9054\u3092\u691c\u7d22 Optional&lt;MyFriends&gt; \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u53d6\u5f97\r\n    private static Optional&lt;MyFriends&gt; findMyFriendsByPhoneNumber(String phoneNumber, List&lt;MyFriends&gt; myFriends) {\r\n        return myFriends\r\n                .stream()\r\n                .filter(e -&gt; Objects.equals(e.getPhoneNumber(), phoneNumber))\r\n                .findFirst();\r\n    }\r\n\r\n    \/\/ \u96fb\u8a71\u756a\u53f7\u3067\u53cb\u9054\u3092\u691c\u7d22\u3057\u3066\u5b58\u5728\u3057\u306a\u304b\u3063\u305f\u5834\u5408\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\r\n    private static void notFoundByPhoneNumber(String phoneNumber) {\r\n        System.out.println(\"\u96fb\u8a71\u756a\u53f7 \" + phoneNumber + \" \u306e\u53cb\u9054\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\");\r\n    }\r\n\r\n    \/\/ ID\u3001\u540d\u524d\u3001\u96fb\u8a71\u756a\u53f7\u306e\u9806\u306b\u53cb\u9054\u3092\u691c\u7d22\u3057\u3066\u8868\u793a\u3059\u308b\r\n    private static void findByMyFriendsIdOrNameOrPhoneNumber(int id, String name, String phoneNumber, List&lt;MyFriends&gt; myFriends) {\r\n        Optional&lt;MyFriends&gt; myFriendsById = findMyFriendsById(id, myFriends);\r\n        Optional&lt;MyFriends&gt; myFriendsByName = findMyFriendsByName(name, myFriends);\r\n        Optional&lt;MyFriends&gt; myFriendsByPhoneNumber = findMyFriendsByPhoneNumber(phoneNumber, myFriends);\r\n        myFriendsById\r\n                .or(() -&gt; myFriendsByName\r\n                .or(() -&gt; myFriendsByPhoneNumber))\r\n                .ifPresentOrElse(MyFriends::printMyFriends, () -&gt; notFoundByIdOrNameOrPhoneNumber(id, name, phoneNumber));\r\n    }\r\n\r\n    \/\/ ID\u3001\u540d\u524d\u3001\u96fb\u8a71\u756a\u53f7\u306e\u9806\u306b\u53cb\u9054\u3092\u691c\u7d22\u3057\u3066\u5b58\u5728\u3057\u306a\u304b\u3063\u305f\u5834\u5408\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\r\n    private static void notFoundByIdOrNameOrPhoneNumber(int id, String name, String phoneNumber) {\r\n        System.out.println(\"ID \" + id + \"\u3001\u540d\u524d \" + name + \"\u3001\u96fb\u8a71\u756a\u53f7 \" + phoneNumber + \"\u306e\u4f55\u308c\u304b\u306b\u5408\u81f4\u3059\u308b\u53cb\u9054\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\");\r\n    }\r\n\r\n    \/\/ \u8077\u696d\u5225\u306b\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u597d\u611f\u5ea6 90 \u4ee5\u4e0a\u306e\u53cb\u9054\u3092\u691c\u7d22\r\n    private static void findByProfession(List&lt;MyFriends&gt; myFriends, int favorabilityRating) {\r\n        \/\/ Java9\r\n        Map&lt;String, List&lt;MyFriends&gt;&gt; myFriendsByProfession\r\n                = myFriends.stream().collect(\r\n                        Collectors.groupingBy(MyFriends::getProfession,\r\n                                Collectors.filtering(e -&gt; e.getFavorabilityRating() &gt;= favorabilityRating,\r\n                                        Collectors.toList())));\r\n\r\n\/\/        \/\/ Java8 No Good!!\r\n\/\/        Map&lt;String, List&lt;MyFriends&gt;&gt; myFriendsByProfession\r\n\/\/                = myFriends.stream()\r\n\/\/                        .filter(e -&gt; e.getFavorabilityRating() &gt;= favorabilityRating)\r\n\/\/                        .collect(\r\n\/\/                                Collectors.groupingBy(MyFriends::getProfession,\r\n\/\/                                        CollectorstoList()));\r\n\/\/        \/\/ Java8\r\n\/\/        Map&lt;String, List&lt;MyFriends&gt;&gt; myFriendsByProfession\r\n\/\/                = myFriends.stream().collect(\r\n\/\/                        Collectors.groupingBy(MyFriends::getProfession,\r\n\/\/                                Collectors.collectingAndThen(Collectors.toList(),\r\n\/\/                                        e -&gt; e.stream()\r\n\/\/                                                .filter(v -&gt; v.getFavorabilityRating() &gt;= favorabilityRating)\r\n\/\/                                                .collect(Collectors.toList()))));\r\n\r\n        myFriendsByProfession.entrySet().forEach(es -&gt; {\r\n            if (es.getValue().isEmpty()) {\r\n                System.out.println(\"Key= \" + es.getKey() + \", \u597d\u611f\u5ea6 \" + favorabilityRating + \"\u4ee5\u4e0a\u306e\u53cb\u9054\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\");\r\n            }\r\n            es.getValue().forEach(v -&gt; {\r\n                System.out.println(\"Key= \" + es.getKey() + \", Value = \" + getMyFriendsInfo(v));\r\n            });\r\n        });\r\n    }\r\n\r\n    private static String getMyFriendsInfo(MyFriends v) {\r\n        return v.getId() + \": \" + v.getName() + \", \" + v.getAge() + \"\u6b73\" + \", Gender: \"\r\n                + v.getGender() + \", \u96fb\u8a71\u756a\u53f7: \" + v.getPhoneNumber()\r\n                + \", \u8077\u696d: \" + v.getProfession() + \", \u51fa\u8eab\u5730: \" + v.getBirthplace()\r\n                + \", \u597d\u611f\u5ea6: \" + v.getFavorabilityRating() + \", \u8da3\u5473: \" + v.getHobby();\r\n    }\r\n\r\n    \/\/ \u51fa\u8eab\u5730\u5225\u306b\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u53cb\u9054\u306e\u540d\u524d\u3092\u691c\u7d22 Java8 \u3067\u554f\u984c\u306a\u3057\u306e\u30b1\u30fc\u30b9\r\n    private static void findByBirthplace(List&lt;MyFriends&gt; myFriends) {\r\n        Map&lt;String, Set&lt;String&gt;&gt; myFriendsByBirthplace\r\n                = myFriends.stream()\r\n                        .collect(\r\n                                Collectors.groupingBy(MyFriends::getBirthplace,\r\n                                        Collectors.mapping(MyFriends::getName, Collectors.toSet())));\r\n\r\n        myFriendsByBirthplace.entrySet().forEach(es -&gt; {\r\n            if (es.getValue().isEmpty()) {\r\n                System.out.println(\"Key= \" + es.getKey() + \" \u306e\u53cb\u9054\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\");\r\n            }\r\n            System.out.println(\"Key= \" + es.getKey() + \", Value = \" + es.getValue());\r\n        });\r\n\r\n    }\r\n\r\n    \/\/ \u8077\u696d\u5225\u306b\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u8da3\u5473\u3092\u691c\u7d22 Java9 \u3067\u30b9\u30de\u30fc\u30c8\u306b\u306a\u308b\r\n    private static void findByHobbyByProfession(List&lt;MyFriends&gt; myFriends) {\r\n        Map&lt;String, Set&lt;String&gt;&gt; myFriendsByHobbyByProfession\r\n                = myFriends.stream()\r\n                        .collect(\r\n                                Collectors.groupingBy(MyFriends::getProfession,\r\n\/\/                                        Collectors.mapping(MyFriends::getHobby, Collectors.toSet()))); \/\/ Map&lt;String, Set&lt;List&lt;String&gt;&gt;&gt; Java8\r\n                                        Collectors.flatMapping(e -&gt; e.getHobby().stream(), Collectors.toSet())));\r\n\r\n        myFriendsByHobbyByProfession.entrySet().forEach(es -&gt; {\r\n            if (es.getValue().isEmpty()) {\r\n                System.out.println(\"Key= \" + es.getKey() + \" \u306e\u8da3\u5473\u306f\u3042\u308a\u307e\u305b\u3093\u3002\");\r\n            }\r\n            System.out.println(\"Key= \" + es.getKey() + \", Value = \" + es.getValue());\r\n        });\r\n\r\n    }\r\n\r\n    \/\/ \u5e74\u9f62\u304c\u82e5\u3044\u9806\u306b\u53cb\u9054\u3092\u8868\u793a\r\n    private static void findByYoungOrder(List&lt;MyFriends&gt; myFriends) {\r\n        myFriends.stream()\r\n                .sorted(Comparator.comparing(MyFriends::getAge))\r\n                .forEach(MyFriends::printMyFriends);\r\n    }\r\n\r\n    \/\/ \u5e74\u9f62\u304c\u82e5\u3044\u9806\u306b\u597d\u611f\u5ea6\u304c70\u672a\u6e80\u306e\u53cb\u9054\u304c\u30d2\u30c3\u30c8\u3059\u308b\u307e\u3067\u691c\u7d22\r\n    private static void findByYoungFriendsByFavorabilityRating(List&lt;MyFriends&gt; myFriends, int favorabilityRating) {\r\n        myFriends.stream()\r\n                .sorted(Comparator.comparing(MyFriends::getAge))\r\n                .takeWhile(e -&gt; e.getFavorabilityRating() &gt;= favorabilityRating)\r\n                .forEach(MyFriends::printMyFriends);\r\n\r\n    }\r\n\r\n    \/\/ \u5e74\u9f62\u304c\u5927\u304d\u3044\u9806\u306b\u597d\u611f\u5ea6\u304c90\u672a\u6e80\u306e\u53cb\u9054\u304c\u30d2\u30c3\u30c8\u3059\u308b\u307e\u3067\u30b9\u30ad\u30c3\u30d7\u3057\u3066\u691c\u7d22\r\n    private static void findByOldFriendsByFavorabilityRating(List&lt;MyFriends&gt; myFriends, int favorabilityRating) {\r\n        myFriends.stream()\r\n                .sorted(Comparator.comparing(MyFriends::getAge).reversed())\r\n                .dropWhile(e -&gt; e.getFavorabilityRating() &lt; favorabilityRating)\r\n                .forEach(MyFriends::printMyFriends);\r\n    }\r\n\r\n    \/\/ \u6761\u4ef6\u4ed8\u304d\u3067\u5e74\u9f62\u304c\u82e5\u3044\u9806\u306b\u53cb\u9054\u3092\u8868\u793a 27\u6b73\u4ee5\u4e0b\u30b9\u30ad\u30c3\u30d7\u300134\u6b73\u307e\u3067 \u30ea\u30df\u30c3\u30c8\r\n    private static void findByConditionalYoungOrder(List&lt;MyFriends&gt; myFriends, int skip, int limit) {\r\n        myFriends.stream()\r\n                .sorted(Comparator.comparing(MyFriends::getAge))\r\n                .dropWhile(e -&gt; e.getAge() &lt;= skip)\r\n                .takeWhile(e -&gt; e.getAge() &lt;= limit)\r\n                .forEach(MyFriends::printMyFriends);\r\n    }\r\n\r\n    \/\/ ID 1 \u304b\u3089 Double Calculation \u3067\u8a08\u7b97\u3057\u3066\u53cb\u9054\u3092\u691c\u7d22  \u305f\u3060\u3057\u3001ID \u306f 50 \u672a\u6e80\u306e\u7bc4\u56f2\u3068\u3059\u308b\u3002\uff08\u5b9f\u8cea 32 \u307e\u3067\uff09\r\n    private static void findByIdDoubleCalculation(List&lt;MyFriends&gt; myFriends, int id) {\r\n        IntStream.iterate(1, i -&gt; i &lt;= id, i -&gt; i *= 2).forEach(i -&gt; {\r\n            findById(i, myFriends);\r\n        });\r\n    }\r\n\r\n}\r\n\r\n<\/pre>\n<p><strong><font size=\"3\">static &lt;E&gt; List&lt;E&gt; of()<\/font><\/strong><\/p>\n<p>Returns an immutable list containing zero elements. See Immutable List Static Factory Methods for details.<\/p>\n<p><strong>Type Parameters:<br \/><\/strong>E &#8211; the List&#8217;s element type<\/p>\n<p><strong>Returns:<br \/><\/strong>an empty List<br \/>&nbsp;<\/p>\n<p><strong><font size=\"3\">public Stream&lt;T&gt; stream()<\/font><\/strong><\/p>\n<p>If a value is present, returns a sequential Stream containing only that value, otherwise returns an empty Stream.<\/p>\n<p><strong>API Note:<\/strong><br \/>This method can be used to transform a Stream of optional elements to a Stream of present value elements:<br \/>&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp; Stream&lt;Optional&lt;T&gt;&gt; os = ..<br \/>&nbsp;&nbsp;&nbsp;&nbsp; Stream&lt;T&gt; s = os.flatMap(Optional::stream)<br \/>&nbsp;<br \/><strong>Returns:<br \/><\/strong>the optional value as a Stream<\/p>\n<p>&nbsp;<\/p>\n<p><strong><font size=\"3\">static &lt;T&gt; Stream&lt;T&gt; ofNullable(T t)<\/font><\/strong><\/p>\n<p>Returns a sequential Stream containing a single element, if non-null, otherwise returns an empty Stream.<\/p>\n<p><strong>Type Parameters:<br \/><\/strong>T &#8211; the type of stream elements<\/p>\n<p><strong>Parameters:<br \/><\/strong>t &#8211; the single element<\/p>\n<p><strong>Returns:<br \/><\/strong>a stream with a single element if the specified element is non-null, otherwise an empty stream<\/p>\n<p>&nbsp;<\/p>\n<p><strong><font size=\"3\">public void ifPresentOrElse(Consumer&lt;? super T&gt; action, Runnable emptyAction)<\/font><\/strong><\/p>\n<p>If a value is present, performs the given action with the value, otherwise performs the given empty-based action.<\/p>\n<p><strong>Parameters:<br \/><\/strong>action &#8211; the action to be performed, if a value is presentemptyAction &#8211; the empty-based action to be performed, if no value is present<\/p>\n<p><strong>Throws:<br \/><\/strong>NullPointerException &#8211; if a value is present and the given action is null, or no value is present and the given empty-based action is null.<\/p>\n<p>&nbsp;<\/p>\n<p><strong><font size=\"3\">public Optional&lt;T&gt; or(Supplier&lt;? extends Optional&lt;? extends T&gt;&gt; supplier)<\/font><\/strong><\/p>\n<p>If a value is present, returns an Optional describing the value, otherwise returns an Optional produced by the supplying function.<\/p>\n<p><strong>Parameters:<br \/><\/strong>supplier &#8211; the supplying function that produces an Optional to be returned<\/p>\n<p><strong>Returns:<br \/><\/strong>returns an Optional describing the value of this Optional, if a value is present, otherwise an Optional produced by the supplying function.<\/p>\n<p><strong>Throws:<\/strong><br \/>NullPointerException &#8211; if the supplying function is null or produces a null result<\/p>\n<p>&nbsp;<\/p>\n<p><strong><font size=\"3\">public static &lt;T,A,R&gt; Collector&lt;T,?,R&gt; filtering(Predicate&lt;? super T&gt; predicate, Collector&lt;? super T,A,R&gt; downstream)<\/font><\/strong><\/p>\n<p>Adapts a Collector to one accepting elements of the same type T by applying the predicate to each input element and only accumulating if the predicate returns true.<\/p>\n<p><strong>API Note:<br \/><\/strong>The filtering() collectors are most useful when used in a multi-level reduction, such as downstream of a groupingBy or partitioningBy. For example, given a stream of Employee, to accumulate the employees in each department that have a salary above a certain threshold:<br \/>&nbsp;<br \/>Map&lt;Department, Set&lt;Employee&gt;&gt; wellPaidEmployeesByDepartment<br \/>&nbsp;&nbsp; = employees.stream().collect(<br \/>&nbsp;&nbsp;&nbsp;&nbsp; groupingBy(Employee::getDepartment,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filtering(e -&gt; e.getSalary() &gt; 2000,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; toSet())));<br \/>&nbsp;<br \/>A filtering collector differs from a stream&#8217;s filter() operation. In this example, suppose there are no employees whose salary is above the threshold in some department. Using a filtering collector as shown above would result in a mapping from that department to an empty Set. If a stream filter() operation were done instead, there would be no mapping for that department at all.<\/p>\n<p><strong>Type Parameters:<br \/><\/strong>T &#8211; the type of the input elements<br \/>A &#8211; intermediate accumulation type of the downstream collector<br \/>R &#8211; result type of collector<\/p>\n<p><strong>Parameters:<\/strong><br \/>predicate &#8211; a predicate to be applied to the input elements<br \/>downstream &#8211; a collector which will accept values that match the predicate<\/p>\n<p><strong>Returns:<br \/><\/strong>a collector which applies the predicate to the input elements and provides matching elements to the downstream collector<\/p>\n<p>&nbsp;<\/p>\n<p><strong><font size=\"3\">public static &lt;T,U,A,R&gt; Collector&lt;T,?,R&gt; flatMapping(Function&lt;? super T,? extends Stream&lt;? extends U&gt;&gt; mapper, Collector&lt;? super U,A,R&gt; downstream)<\/font><\/strong><\/p>\n<p>Adapts a Collector accepting elements of type U to one accepting elements of type T by applying a flat mapping function to each input element before accumulation. The flat mapping function maps an input element to a stream covering zero or more output elements that are then accumulated downstream. Each mapped stream is closed after its contents have been placed downstream. (If a mapped stream is null an empty stream is used, instead.)<\/p>\n<p><strong>API Note:<br \/><\/strong>The flatMapping() collectors are most useful when used in a multi-level reduction, such as downstream of a groupingBy or partitioningBy. For example, given a stream of Order, to accumulate the set of line items for each customer:<br \/>&nbsp;<br \/>Map&lt;String, Set&lt;LineItem&gt;&gt; itemsByCustomerName<br \/>&nbsp;&nbsp; = orders.stream().collect(<br \/>&nbsp;&nbsp;&nbsp;&nbsp; groupingBy(Order::getCustomerName,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flatMapping(order -&gt; order.getLineItems().stream(),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; toSet())));<br \/>&nbsp;<br \/><strong>Type Parameters:<br \/><\/strong>T &#8211; the type of the input elements<br \/>U &#8211; type of elements accepted by downstream collector<br \/>A &#8211; intermediate accumulation type of the downstream collector<br \/>R &#8211; result type of collector<\/p>\n<p><strong>Parameters:<\/strong><br \/>mapper &#8211; a function to be applied to the input elements, which returns a stream of results<br \/>downstream &#8211; a collector which will receive the elements of the stream returned by mapper<\/p>\n<p><strong>Returns:<br \/><\/strong>a collector which applies the mapping function to the input elements and provides the flat mapped results to the downstream collector<\/p>\n<p>&nbsp;<\/p>\n<p><strong><font size=\"3\">default Stream&lt;T&gt; takeWhile(Predicate&lt;? super T&gt; predicate)<\/font><\/strong><\/p>\n<p>Returns, if this stream is ordered, a stream consisting of the longest prefix of elements taken from this stream that match the given predicate. Otherwise returns, if this stream is unordered, a stream consisting of a subset of elements taken from this stream that match the given predicate.<br \/>&nbsp;<br \/>If this stream is ordered then the longest prefix is a contiguous sequence of elements of this stream that match the given predicate. The first element of the sequence is the first element of this stream, and the element immediately following the last element of the sequence does not match the given predicate. <\/p>\n<p>If this stream is unordered, and some (but not all) elements of this stream match the given predicate, then the behavior of this operation is nondeterministic; it is free to take any subset of matching elements (which includes the empty set). <\/p>\n<p>Independent of whether this stream is ordered or unordered if all elements of this stream match the given predicate then this operation takes all elements (the result is the same as the input), or if no elements of the stream match the given predicate then no elements are taken (the result is an empty stream). <\/p>\n<p>This is a short-circuiting stateful intermediate operation.<\/p>\n<p><strong>API Note:<br \/><\/strong>While takeWhile() is generally a cheap operation on sequential stream pipelines, it can be quite expensive on ordered parallel pipelines, since the operation is constrained to return not just any valid prefix, but the longest prefix of elements in the encounter order. Using an unordered stream source (such as generate(Supplier)) or removing the ordering constraint with BaseStream.unordered() may result in significant speedups of takeWhile() in parallel pipelines, if the semantics of your situation permit. If consistency with encounter order is required, and you are experiencing poor performance or memory utilization with takeWhile() in parallel pipelines, switching to sequential execution with BaseStream.sequential() may improve performance.<\/p>\n<p>Implementation Requirements:<br \/>The default implementation obtains the spliterator of this stream, wraps that spliterator so as to support the semantics of this operation on traversal, and returns a new stream associated with the wrapped spliterator. The returned stream preserves the execution characteristics of this stream (namely parallel or sequential execution as per BaseStream.isParallel()) but the wrapped spliterator may choose to not support splitting. When the returned stream is closed, the close handlers for both the returned and this stream are invoked.<\/p>\n<p><strong>Parameters:<\/strong><br \/>predicate &#8211; a non-interfering, stateless predicate to apply to elements to determine the longest prefix of elements.<\/p>\n<p><strong>Returns:<\/strong><br \/>the new stream<\/p>\n<p>&nbsp;<\/p>\n<p><strong><font size=\"3\">default Stream&lt;T&gt; dropWhile(Predicate&lt;? super T&gt; predicate)<\/font><\/strong><\/p>\n<p>Returns, if this stream is ordered, a stream consisting of the remaining elements of this stream after dropping the longest prefix of elements that match the given predicate. Otherwise returns, if this stream is unordered, a stream consisting of the remaining elements of this stream after dropping a subset of elements that match the given predicate.<br \/>&nbsp;<br \/>If this stream is ordered then the longest prefix is a contiguous sequence of elements of this stream that match the given predicate. The first element of the sequence is the first element of this stream, and the element immediately following the last element of the sequence does not match the given predicate. <\/p>\n<p>If this stream is unordered, and some (but not all) elements of this stream match the given predicate, then the behavior of this operation is nondeterministic; it is free to drop any subset of matching elements (which includes the empty set). <\/p>\n<p>Independent of whether this stream is ordered or unordered if all elements of this stream match the given predicate then this operation drops all elements (the result is an empty stream), or if no elements of the stream match the given predicate then no elements are dropped (the result is the same as the input). <\/p>\n<p>This is a stateful intermediate operation.<\/p>\n<p><strong>API Note:<br \/><\/strong>While dropWhile() is generally a cheap operation on sequential stream pipelines, it can be quite expensive on ordered parallel pipelines, since the operation is constrained to return not just any valid prefix, but the longest prefix of elements in the encounter order. Using an unordered stream source (such as generate(Supplier)) or removing the ordering constraint with BaseStream.unordered() may result in significant speedups of dropWhile() in parallel pipelines, if the semantics of your situation permit. If consistency with encounter order is required, and you are experiencing poor performance or memory utilization with dropWhile() in parallel pipelines, switching to sequential execution with BaseStream.sequential() may improve performance.<\/p>\n<p><strong>Implementation Requirements:<\/strong><br \/>The default implementation obtains the spliterator of this stream, wraps that spliterator so as to support the semantics of this operation on traversal, and returns a new stream associated with the wrapped spliterator. The returned stream preserves the execution characteristics of this stream (namely parallel or sequential execution as per BaseStream.isParallel()) but the wrapped spliterator may choose to not support splitting. When the returned stream is closed, the close handlers for both the returned and this stream are invoked.<\/p>\n<p><strong>Parameters:<br \/><\/strong>predicate &#8211; a non-interfering, stateless predicate to apply to elements to determine the longest prefix of elements.<\/p>\n<p><strong>Returns:<br \/><\/strong>the new stream<\/p>\n<p>&nbsp;<\/p>\n<p><strong><font size=\"3\">static IntStream iterate(int seed, IntPredicate hasNext, IntUnaryOperator next)<\/font><\/strong><\/p>\n<p>Returns a sequential ordered IntStream produced by iterative application of the given next function to an initial element, conditioned on satisfying the given hasNext predicate. The stream terminates as soon as the hasNext predicate returns false.<br \/>&nbsp;<br \/>IntStream.iterate should produce the same sequence of elements as produced by the corresponding for-loop: <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; for (int index=seed; hasNext.test(index); index = next.applyAsInt(index)) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8230;<br \/>&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;<\/p>\n<p>The resulting sequence may be empty if the hasNext predicate does not hold on the seed value. Otherwise the first element will be the supplied seed value, the next element (if present) will be the result of applying the next function to the seed value, and so on iteratively until the hasNext predicate indicates that the stream should terminate. <\/p>\n<p>The action of applying the hasNext predicate to an element happens-before the action of applying the next function to that element. The action of applying the next function for one element happens-before the action of applying the hasNext predicate for subsequent elements. For any given element an action may be performed in whatever thread the library chooses.<\/p>\n<p><strong>Parameters:<\/strong><br \/>seed &#8211; the initial element<br \/>hasNext &#8211; a predicate to apply to elements to determine when the stream must terminate.<br \/>next &#8211; a function to be applied to the previous element to produce a new element<\/p>\n<p><strong>Returns:<br \/><\/strong>a new sequential IntStream<\/p>\n<p>&nbsp;<\/p>\n<p><strong><font size=\"3\">static &lt;T&gt; Stream&lt;T&gt; iterate(T seed, Predicate&lt;? super T&gt; hasNext, UnaryOperator&lt;T&gt; next)<\/font><\/strong><\/p>\n<p>Returns a sequential ordered Stream produced by iterative application of the given next function to an initial element, conditioned on satisfying the given hasNext predicate. The stream terminates as soon as the hasNext predicate returns false.<br \/>&nbsp;<br \/>Stream.iterate should produce the same sequence of elements as produced by the corresponding for-loop: <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; for (T index=seed; hasNext.test(index); index = next.apply(index)) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8230;<br \/>&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;<\/p>\n<p>The resulting sequence may be empty if the hasNext predicate does not hold on the seed value. Otherwise the first element will be the supplied seed value, the next element (if present) will be the result of applying the next function to the seed value, and so on iteratively until the hasNext predicate indicates that the stream should terminate. <\/p>\n<p>The action of applying the hasNext predicate to an element happens-before the action of applying the next function to that element. The action of applying the next function for one element happens-before the action of applying the hasNext predicate for subsequent elements. For any given element an action may be performed in whatever thread the library chooses.<\/p>\n<p><strong>Type Parameters:<\/strong><br \/>T &#8211; the type of stream elements<\/p>\n<p><strong>Parameters:<\/strong><br \/>seed &#8211; the initial element<br \/>hasNext &#8211; a predicate to apply to elements to determine when the stream must terminate.<br \/>next &#8211; a function to be applied to the previous element to produce a new element<\/p>\n<p><strong>Returns:<\/strong><br \/>a new sequential Stream<\/p>\n<p>&nbsp;<\/p>\n<p>API \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u304c\u82f1\u8a9e\u3057\u304b\u306a\u3044\u306e\u304c\u6b8b\u5ff5(&gt;_&lt;)<\/p>\n<p>\u6b63\u5f0f\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u308b\u9803\u306b\u306f\u65e5\u672c\u8a9e\u7248\u304c\u51fa\u308b\u3053\u3068\u3092\u7948\u308d\u3046\uff01<\/p>\n<p>Java SE 8 \u304b\u3089\u306e\u75d2\u3044\u3068\u3053\u308d\u306b\u624b\u304c\u5c4a\u3044\u305f\u3088\u3046\u306a\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3060\u3051\u3069\u304b\u306a\u308a\u4fbf\u5229\u306b\u306a\u308b\u3002<\/p>\n<p>\u306a\u305c\u521d\u3081\u304b\u3089\u3053\u3046\u3057\u306a\u304b\u3063\u305f\u3093\u3060\u308d\u3046\u3068\u601d\u3046\u307b\u3069\u306b\u3002<\/p>\n<p>\u3067\u3082 zip, pair \u306f\u307e\u3060\u7121\u3044\u307e\u307e\u30fb\u30fb\u30fb<\/p>\n<p>Java SE 10 \u307e\u3067\u5f85\u3064\u3053\u3068\u306b\u306a\u308b\u306e\u304b\u5fc5\u8981\u306a\u3044\u3068\u5224\u65ad\u3055\u308c\u305f\u306e\u304b\uff1f<\/p>\n<p>\u4ed6\u306b\u3082\u3044\u308d\u3044\u308d\u7d30\u304b\u3044\u3068\u3053\u308d\u304c\u826f\u304f\u306a\u3063\u3066\u3044\u308b\u3088\u3046\u3060\u304b\u3089\u6b63\u5f0f\u30ea\u30ea\u30fc\u30b9\u304c\u697d\u3057\u307f\u3067\u3059\u306d\uff01<\/p>\n<div id=\"scid:0767317B-992E-4b12-91E0-4F059A8CECA8:53466076-e0c8-4cb4-9fee-98b107da1e4c\" class=\"wlWriterEditableSmartContent\" style=\"float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px\">Hatena \u30bf\u30b0: <a href=\"http:\/\/b.hatena.ne.jp\/t\/Java\" rel=\"tag\">Java<\/a><\/div>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_hatena\"><a href='\/\/b.hatena.ne.jp\/add?mode=confirm&url=http%3A%2F%2Fyucchi.jp%2Fblog%2F%3Fp%3D2295&title=Java%20SE%209%20%E3%81%AE%E4%BA%88%E7%BF%92' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='http:\/\/yucchi.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/hatena.gif' alt='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' width='16' height='12' class='wp_social_bookmarking_light_img' \/><\/a><\/div>\n            <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=http%3A%2F%2Fyucchi.jp%2Fblog%2F%3Fp%3D2295&t=Java%20SE%209%20%E3%81%AE%E4%BA%88%E7%BF%92' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='http:\/\/yucchi.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"http:\/\/yucchi.jp\/blog\/?p=2295\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"http:\/\/yucchi.jp\/blog\/?p=2295\" data-text=\"Java SE 9 \u306e\u4e88\u7fd2\" data-lang=\"ja\">Tweet<\/a><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u65e5\u306f\u79c1\u306e\u25cb\uff38\u56de\u76ee\u306e\u8a95\u751f\u65e5\u3067\u3059\u3002 \u4eca\u5e74\u306f\u5fd8\u308c\u3089\u308c\u305a\u306b\u304a\u795d\u3044\u306e\u30d7\u30ec\u30bc\u30f3\u30c8\u307e\u3067\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002(^_^) \u3044\u304f\u3064\u306b\u306a\u3063\u3066\u3082\u8a95\u751f\u65e5\u3092\u795d\u3063\u3066\u3082\u3089\u3048\u308b\u306e\u306f\u5b09\u3057\u3044\u3082\u306e\u3067\u3059\u3002 \u3068\u8a00\u3046\u308f\u3051\u3067\u304a\u8a95\u751f\u65e5\u8a18\u5ff5\u3068\u3057\u3066\u4eca\u5e74\u306e\u590f\u306b\u30ea\u30ea\u30fc\u30b9\u4e88\u5b9a\u306e Java SE 9 \u306e\u4e88\u7fd2\u3092\u306f\u3058\u3081\u307e\u3059\u3002 Java SE 9 \u3068\u8a00\u3048\u3070 Project Jigsaw, Project Kulla (JShell) \u304c\u76ee\u7389\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002 \u3053\u308c\u3089\u306f\u3053\u308c\u304b\u3089\u65e5\u672c\u8a9e\u3067\u306e\u60c5\u5831\u3082\u305f\u304f\u3055\u3093\u51fa\u3066\u304f\u308b\u3068\u601d\u3046\u306e\u3067\u5f8c\u56de\u3057\u3068\u3057\u307e\u3059\u3002(\u65e2\u306b\u6700\u65b0Java\u60c5\u5831\u5c40\u3067\u8a18\u4e8b\u304c\u3042\u308a\u307e\u3059\u3002) \u6545\u306b Java SE 9 \u3092\u4f7f\u3046\u306e\u3067\u3042\u308c\u3070\u5fc5\u8981\u6700\u4f4e\u9650\u3053\u308c\u3060\u3051\u306f\u899a\u3048\u3066\u304a\u304d\u305f\u3044\u3053\u3068\u3092\u81ea\u5206\u7528\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[17],"class_list":["post-2295","post","type-post","status-publish","format-standard","hentry","category-java","tag-java"],"_links":{"self":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2295"}],"version-history":[{"count":1,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2295\/revisions"}],"predecessor-version":[{"id":2296,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2295\/revisions\/2296"}],"wp:attachment":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2295"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}