Stream API 入門 #jjug #javajo

Stream API 入門 #jjug #javajo

Java女子部「Java本格入門!!!著者をお招きしちゃうよ(*´∀`*) 」
https://javajo.doorkeeper.jp/events/60742

JJUG ナイトセミナー 「Java エンジニアのためのJava(再)入門」
https://jjug.doorkeeper.jp/events/61857

Ad3fbc316f916a341c24035e34913121?s=128

Shin Tanimoto

June 11, 2017
Tweet

Transcript

  1. 4USFBN"1*ೖ໳ ʙ͍·͞Βฉ͚ͳ͍4USFBNͷΩϗϯ "DSPRVFTU5FDIOPMPHZגࣜձࣾ
 ೔ຊ+BWBϢʔβʔάϧʔϓ ୩ຊ৺ !DFSP@U

  2. ͳͥɺ4USFBN"1*Λ
 ֶͿ΂͖ͳͷ͔ʁ

  3. ৽͍͔͠Βʁ ੑೳ͕͍͍͔Βʁ ؆ܿʹॻ͚Δ͔Βʁ

  4. 4USFBN"1*ͷΑ͏ͳ
 ෺ࣄͷଊ͑ํ͕ࠓޙ਺೥ͷ
 ίʔσΟϯάʹඞཁͱ
 ͳͬͯ͘Δ͔Β

  5. ৄ͍͠࿩͸ޙͰ΍Γ·͢

  6. ·ͣ͸ʮ؆ܿʹॻ͚Δ͔Βʯ
 ͩͱଊ͑ͯ࢝Ί·͠ΐ͏

  7. 5BCMFPG$POUFOUT w 4USFBN"1*ͱ͸ʁ w -BNCEBࣜͱ͸ʁ w 4USFBN"1*ͷॻ͖ํͱɺԡ͑͞ΔϙΠϯτ w ͳͥ4USFBN"1*͕ॏཁͳͷ͔

  8. 4USFBN"1*ͱ͸ʁ

  9. 4USFBNྲྀΕ

  10. None
  11. ৄ͍͠࿩͸ޙͰ΍Γ·͢

  12. େྔσʔλΛஞ࣍ॲཧ͢Δ
 ʮετϦʔϜॲཧʯΛ
 ؆ܿʹॻͨ͘Ίͷ"1*

  13. ͚ͩͲɺ
 ίϨΫγϣϯͷૢ࡞Λ
 ؆ܿʹॻ͘͜ͱ΋Ͱ͖Δ

  14. List<Student> students = new ArrayList<>(); students.add(new Student("Ken", 100)); students.add(new Student("Shin",

    60)); students.add(new Student("Takuya", 80)); for (Student student : students) { if (student.getScore() >= 70) { System.out.println(student); } } ͜Ε͕
  15. List<Student> students = new ArrayList<>(); students.add(new Student("Ken", 100)); students.add(new Student("Shin",

    60)); students.add(new Student("Takuya", 80)); 
 students.stream() .filter(s -> s.getScore() >= 70) .forEach(System.out::println); ͜͏ͳΔ
  16. ίϨΫγϣϯͷ
 ߜΓࠐΈɺม׵΍ɺ
 ͦΕͧΕͷཁૉ΁ͷॲཧɺ
 ूܭͳͲ͕Ͱ͖Δ

  17. ͱ͸ݴ͑

  18. Map<Dept, Long> groupByDeptAndFilter(List<Emp> list) { return list.stream() .collect(Collectors.groupingBy(emp -> emp.dept))

    .entrySet() .stream() .collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue() .stream() .filter(emp -> emp.sal > 1000) .count())); }
  19. Կ͜ΕಡΊͳ͍

  20. GPSจΛ࢖ͬͯ
 ॻ͖௚͢ͱ

  21. Map<Dept, Long> groupByDeptClassic(List<Emp> list) { Map<Dept, Long> result = new

    HashMap<>(); for (Emp emp : list) { if (result.containsKey(emp.dept) == false) { result.put(emp.dept, 0L); } if (emp.sal > 1000) { Long count = result.get(emp.dept); count++; result.put(emp.dept, count); } } return result; }
  22. ಡΈ΍͍͢ʂ
 ✌ Т✌ ࡾ✌ Т ✌ࡾ ✌Т ✌

  23. Έ͍ͨͳ͜ͱʹͳΔͷͰ
 ແཧͯ͠ෳࡶͳ΋ͷΛ
 4USFBN"1*Ͱ
 ॻ͘ඞཁ͸ͳ͍Ͱ͢

  24. ৽͍͠΋ͷΛ࢖͏͜ͱ͕
 ৗʹΤϥ͍Θ͚͡Όͳ͍

  25. ผʹੑೳ΋มΘΜͳ͍

  26. ·ͣ͸جຊతͳॻ͖ํͱ
 ͦͷ֓೦Λֶͼ·͠ΐ͏

  27. -BNCEBࣜͱ͸ʁ

  28. ˓ϥϜμࣜ
 ºϥϯόμࣜ

  29. List<Student> students = new ArrayList<>(); students.add(new Student("Ken", 100)); students.add(new Student("Shin",

    60)); students.add(new Student("Takuya", 80)); 
 students.stream() .filter(s -> s.getScore() >= 70) .forEach(System.out::println); ͜ͷ෦෼
  30. 4USFBN"1*Λ
 ؆ܿʹॻͨ͘Ίʹ
 ͔ܽͤͳ͍΋ͷ

  31. -BNCEBࣜͱ͸
 ࣮૷͢΂͖ϝιου͕
 ͔ͭ͠ͳ͍ΠϯλϑΣʔεΛ
 ؆ܿʹදهͰ͖Δ΋ͷ

  32. ͨͱ͑͹ KBWBVUJM$PNQBSBUPS
 
 ࣮૷͢Δ΂͖ϝιου͸
 DPNQBSF

  33. void sort() { List<Student> studentList = new ArrayList<>(); studentList.add(new Student("Murata",

    100)); studentList.add(new Student("Okada", 70)); studentList.add(new Student("Tanimoto", 80)); System.out.println(studentList); Collections.sort(studentList, new StudentComparator()); System.out.println(studentList); } class StudentComparator implements Comparator<Student> { @Override public int compare(Student student1, Student student2) { return Integer.compare(student1.getScore(), student2.getScore()); } } ͜ͷ෦෼
  34. void sortAnonymous() { List<Student> studentList = new ArrayList<>(); studentList.add(new Student("Murata",

    100)); studentList.add(new Student("Okada", 70)); studentList.add(new Student("Tanimoto", 80)); System.out.println(studentList); Collections.sort(studentList, new Comparator<Student>() { @Override public int compare(Student student1, Student student2) { return Integer.compare(student1.getScore(), student2.getScore()); } }); System.out.println(studentList); } ແ໊ΫϥεΛ࢖͏ͱ
  35. void sortLambda() { List<Student> studentList = new ArrayList<>(); studentList.add(new Student("Murata",

    100)); studentList.add(new Student("Okada", 70)); studentList.add(new Student("Tanimoto", 80)); System.out.println(studentList); Collections.sort(studentList, (student1, student2) -> Integer.compare(student1.getScore(), student2.getScore())); System.out.println(studentList); } -BNCEBΛ࢖͏ͱ
  36. ࣮૷͢΂͖ϝιου͕
 ͔ͭ͠ͳ͍ΠϯλϑΣʔεΛ
 ʮؔ਺ܕΠϯλϑΣʔεʯ
 ͬͯݺͼ·͢

  37. 4USFBN"1*ͷҾ਺͸
 جຊతʹ͢΂ͯ
 ؔ਺ܕΠϯλϑΣʔε

  38. 4USFBN"1*Λ͢΂ͯ
 ແ໊ΫϥεͰ࡞Δͱ
 ಡΈͮΒͯ͘࢓ํͳ͍ͷͰ
 ؔ਺ͬΆ͘ॻ͚Δ
 -BNCEB͕ࣜಋೖ͞Εͨ

  39. List<Student> students = new ArrayList<>(); students.add(new Student("Ken", 100)); students.add(new Student("Shin",

    60)); students.add(new Student("Takuya", 80)); 
 students.stream() .filter(s -> s.getScore() >= 70) .forEach(System.out::println); ΋͜͠Ε͕
  40. List<Student> students = new ArrayList<>(); students.add(new Student("Ken", 100)); students.add(new Student("Shin",

    60)); students.add(new Student("Takuya", 80)); students.stream() .filter(new Predicate<Student>() { @Override public boolean test(Student student) { return student.getScore() >= 70; } }) .forEach(new Consumer<Student>() { @Override public void accept(Student student) { System.out.println(student); } }); ͜͏ͳΒ
  41. ୭΋͓લΛѪ͞ͳ͍

  42. -BNCEBࣜͷจ๏

  43. -BNCEBࣜͷجຊจ๏
 
 Ҿ਺ \ॲཧ^

  44. (Student student1, Student student2) -> { int score1 = student1.getScore();

    int score2 = student2.getScore(); return Integer.compare(score1, score2); } (Student student) -> {
 System.out.println(student); } () -> {
 System.out.println("Hello!"); }
  45. Ҿ਺ͷܕ͸লུͰ͖Δ

  46. (Student student1, Student student2) -> { int score1 = student1.getScore();

    int score2 = student2.getScore(); return Integer.compare(score1, score2); } (student1, student2) -> { int score1 = student1.getScore(); int score2 = student2.getScore(); return Integer.compare(score1, score2); }
  47. ॲཧ͕ߦͳΒ SFUVSOͱ\^͕
 লུͰ͖Δ

  48. (student1, student2) -> { int score1 = student1.getScore(); int score2

    = student2.getScore(); return Integer.compare(score1, score2); } 
 
 (student1, student2) -> { return Integer.compare(student1.getScore(), student2.getScore()); } (student1, student2) -> Integer.compare(student1.getScore(), student2.getScore())
  49. Ҿ਺͕ͭͳΒ
  ΋লུͰ͖Δ

  50. (Student student) -> {
 System.out.println(student); } 
 
 
 student

    -> System.out.println(student)
  51. -BNCEBͷத਎͕
 ϝιουݺͼग़ͭ͠Ͱ
 Ҿ਺΋໌֬ͳΒ
 ϝιουࢀর͕࢖͑Δ

  52. ϝιουࢀরͷจ๏ Ϋϥε໊ϝιου໊

  53. (Student student) -> {
 System.out.println(student); } 
 
 
 student

    -> System.out.println(student) System.out::println
  54. (Student student) -> {
 return student.getScore(); } 
 
 


    student -> student.getScore(); Student::getScore
  55. List<Student> students = new ArrayList<>(); students.add(new Student("Ken", 100)); students.add(new Student("Shin",

    60)); students.add(new Student("Takuya", 80)); 
 students.stream() .filter(s -> s.getScore() >= 70) .forEach(System.out::println); ݁Ռɺ͜͏ͳΔ
  56. ͜͜·Ͱ͸0,ʁ

  57. 4USFBN"1*ͷॻ͖ํͱ
 ԡ͑͞ΔϙΠϯτ

  58. ࡞Δ ૢ࡞͢Δ ·ͱΊΔ

  59. Α͘࢖͏ύλʔϯ
 TUSFBN Ͱ࡞Γ NBQ ͰՃ޻͠
 pMUFS ͰߜΓࠐΈ
 DPMMFDU Ͱཉ͍͠ܗʹ͢Δ

  60. ࡞Δ

  61. 4USFBNΛฦ͢"1*Λ
 ݺͼग़͢͜ͱͰ
 4USFBNΛ࡞Δ

  62. List<String> lines = Arrays.asList("Murata=100", "Okada=60", "Tanimoto=80"); List<Student> students = lines.stream()

    .map(s -> { String[] strings = s.split("="); return new Student(strings[0], Integer.valueOf(strings[1])); }) .filter(s -> s.getScore() >= 70) .collect(Collectors.toList()); $PMMFDUJPOTUSFBN
  63. String[] lines = {"Murata=100", "Okada=60", "Tanimoto=80"}; List<Student> students = Arrays.stream(lines)

    .map(s -> { String[] strings = s.split("="); return new Student(strings[0], Integer.valueOf(strings[1])); }) .filter(s -> s.getScore() >= 70) .collect(Collectors.toList()); "SSBZTTUSFBN
  64. .BQͳΒ FOUSZ4FU TUSFBN  ϑΝΠϧΛߦͣͭಡΉͳΒ 'JMFTMJOFT  #VGGFSFE3FBEFSMJOFT

  65. ૢ࡞͢Δ
 ʢதؒૢ࡞ʣ

  66. ઈରʹ֮͑ͯཉ͍͠ NBQͱpMUFS

  67. ม׵΍ߜΓࠐΈͳͲͷ
 ૢ࡞Λߦ͏ͷ͕தؒૢ࡞

  68. NBQ
 ཁૉΛผͷཁૉʹม׵͢Δ pMUFS ৚݅Λࢦఆͯ͠ߜΓࠐΉ

  69. List<String> lines = Arrays.asList("Murata=100", "Okada=60", "Tanimoto=80"); List<Student> students = lines.stream()

    .map(s -> { String[] strings = s.split("="); return new Student(strings[0], Integer.valueOf(strings[1])); }) .filter(s -> s.getScore() >= 70) .collect(Collectors.toList()); } NBQͱpMUFS
  70. List<String> lines = Arrays.asList("Murata=100", "Okada=60", "Tanimoto=80"); List<Student> students = lines.stream()

    .map(s -> { String[] strings = s.split("="); return new Student(strings[0], Integer.valueOf(strings[1])); })
 // この時点でStudentのstreamになる .filter(s -> s.getScore() >= 70) // この時点でMurataとTanimotoが残ったstreamになる .collect(Collectors.toList()); } NBQͱpMUFS
  71. MJNJUͰ݅਺ΛߜΔ EJTUJODUͰϢχʔΫʹߜΔ
 TPSUFEͰฒ΂ม͑Δ
 ͳͲͳͲ

  72. Α͋͘Δޡղࠞཚ

  73. NBQͳͲͷม׵ॲཧͰ͸
 ཁૉͷ਺͸มΘΒͳ͍

  74. ཁૉΛ͍͔ͭ͘·ͱΊͯ
 ॲཧ͢Δ
 Έ͍ͨͳ͜ͱ͸Ͱ͖ͳ͍
 ʢྫɿෳ਺ߦͷϩάϑΝΠϧॲཧʣ

  75. ͋͘·Ͱɺ݅݅ɺ
 Կ͔͢Δ͍ͬͯ͏΋ͷ

  76. pMUFSͰ෼ذ͢Δ͜ͱ͸
 Ͱ͖ͳ͍

  77. ͜ͷ৚݅ͷ4USFBNɺ
 ͦͷ৚݅ͷ4USFBNɺ
 ͋ͷ৚݅ͷ4USFBNɺ
 ͲΕʹ΋֘౰͠ͳ͍4USFBN
 Έ͍ͨͳ͜ͱ͸Ͱ͖ͳ͍

  78. ͋͘·Ͱ΋
 4USFBN͸ຊ

  79. qBU.BQΛ࢖͑͹ ͭͷཁૉ͔Β
 ෳ਺ͷཁૉΛ
 ࡞Δ͜ͱ͸Ͱ͖Δ

  80.          ͔Β

             ͸࡞ΕΔ
  81. Ͱ΋આ໌͸ׂѪ͢ΔΑʂ

  82. ·ͱΊΔ
 ʢऴ୺ૢ࡞ʣ

  83. 4USFBNΛ
 -JTUʹͨ͠Γ.BQʹͨ͠Γ ߹ܭ஋΍ฏۉ஋Λܭࢉͨ͠Γ

  84. ࠷ޙʹ݁Ռͱͯ͠
 औΓग़͢΋ͷ͕
 ऴ୺ૢ࡞

  85. Ұ൪࢖͏ͷ͕
 DPMMFDUͱ$PMMFDUPSTͷ
 ૊Έ߹Θͤ

  86. List<String> lines = Arrays.asList("Murata=100", "Okada=60", "Tanimoto=80"); List<Student> students = lines.stream()

    .map(s -> { String[] strings = s.split("="); return new Student(strings[0], Integer.valueOf(strings[1])); }) .filter(s -> s.getScore() >= 70) .collect(Collectors.toList()); } DPMMFDU
  87. $PMMFDUPSTUP4FU
 $PMMFDUPSTUP.BQ Ͱ4FU΍.BQʹม׵

  88. String[] lines = {"Murata=100", "Okada=60", "Tanimoto=80"}; Map<String, Student> students =

    Arrays.stream(lines) .map(s -> { String[] strings = s.split("="); return new Student(strings[0], Integer.valueOf(strings[1])); }) .collect(Collectors.toMap(s -> s.getName(), s -> s)); return students; $PMMFDUPSTUP.BQ
  89. $PMMFDUPSTKPJOJOHͰ
 શ෦ͭͳ͛ͨจࣈྻʹม׵

  90. $PMMFDUPSTHSPVQJOH#Z Ͱ
 -JTUͷ.BQΛ࡞Δ

  91. DPMMFDUҎ֎ͷऴ୺ૢ࡞

  92. GPS&BDI
 ೚ҙͷॲཧΛ͢Δ
 ʢ໭Γ஋ͳ͠ʣ

  93. NBY NJO
 ࠷େͷ݅ɺ࠷খͷ݅ΛऔΔ pOE'JSTU
 ࠷ॳͷ݅ΛऔΔ

  94. ਺஋ͷ4USFBNͳΒ
 BWFSBHFͱ͔΋औΕΔ

  95. ཁ͢Δʹ
 4USFBNΛ
 ԿΒ͔ͷܗͰ
 ू໿ͯ͠औΓग़͢΋ͷ

  96. ऴ୺ૢ࡞͸
 Ұճ͔͠Ͱ͖ͳ͍

  97. UP-JTUͱGPS&BDIͷ
 ྆ํΛ͢Δ͜ͱ͸Ͱ͖ͳ͍

  98. ͱ͍͏ลΓΛ౿·͑ͯ
 GSPNPME+BWB
 UPNPEFSO+BWB

  99. List<Transaction> list = new ArrayList<>(); try (BufferedReader reader = Files.newBufferedReader(Paths.get(fileName)))

    { String line; while ((line = reader.readLine()) != null) { String[] s = line.split(","); Transaction tx = new Transaction(); tx.date = LocalDate.parse(s[0]); tx.accountId = s[1]; tx.amount = Integer.valueOf(s[2]); tx.name = s[3]; tx.note = s[4]; list.add(tx); } } catch (IOException e) { throw new RuntimeException("failed to parse date or read file", e); } return list; GSPN
  100. try (Stream<String> stream = Files.lines(Paths.get(fileName))) { return stream .map(line ->

    { String[] s = line.split(","); Transaction tx = new Transaction(); tx.date = LocalDate.parse(s[0]); tx.accountId = s[1]; tx.amount = Integer.valueOf(s[2]); tx.name = s[3]; tx.note = s[4]; return tx; }) .collect(Collectors.toList()); } catch (IOException e) { throw new UncheckedIOException("failed to read file", e); } UP4USFBN
  101. try (Stream<String> stream = Files.lines(Paths.get(fileName))) { return stream .map(line ->

    { String[] s = line.split(","); Transaction tx = new Transaction(); tx.date = LocalDate.parse(s[0]); tx.accountId = s[1]; tx.amount = Integer.valueOf(s[2]); tx.name = s[3]; tx.note = s[4]; return tx; }) .collect(Collectors.toList()); } catch (IOException e) { throw new UncheckedIOException("failed to read file", e); } UP4USFBN ϑΝΠϧΛಡΈࠐΜͰ
 Streamͱͯ͠ฦ͢ϝιου
 ʢߦ͝ͱʹॲཧʣ ߦͷStringΛ
 Transactionʹม׵ Listʹͯ͠ฦ͢
  102. // 取引履歴の取得 List<Transaction> list = read(fileName); // 全件表示 for (Transaction

    tx : list) { System.out.println(tx); } // 残高の計算 int sum = 0; for (Transaction tx : list) { sum += tx.amount; } System.out.println(sum); // 6月分のみ表示 for (Transaction tx : list) { if (tx.date.getMonth() == Month.JUNE) { System.out.println(tx); } } GSPN
  103. // 取引履歴の取得 read(fileName).stream() .forEach(System.out::println); // 残高の計算 int sum = read(fileName).stream()

    .mapToInt(tx -> tx.amount) .sum(); System.out.println(sum); // 6月分のみ表示 read(fileName).stream() .filter(tx -> tx.date.getMonth() == Month.JUNE) .forEach(System.out::println); UP4USFBN
  104. // 取引履歴の取得 read(fileName).stream() .forEach(System.out::println); // 残高の計算 int sum = read(fileName).stream()

    .mapToInt(tx -> tx.amount) .sum(); System.out.println(sum); // 6月分のみ表示 read(fileName).stream() .filter(tx -> tx.date.getMonth() == Month.JUNE) .forEach(System.out::println); UP4USFBN ͢΂ͯͷཁૉʹ͍ͭͯ
 ॱ൪ʹॲཧ औҾֹΛint஋ͱͯ͠औΓग़ͯ͠
 intͷstreamʢIntStreamʣʹ͔ͯ͠Β
 ߹ܭ஋Λऔಘ 6݄ͷΈΛऔΓग़ͯ͠
 શ݅දࣔ
  105. ΋͏গ͠ࠐΈೖͬͨ಺༰͸
 ϥΠϒίʔσΟϯάͰ

  106. ͳͥ4USFBN"1*͕
 ॏཁͳͷ͔ʁ

  107. $PMMFDUJPOΛ؆ܿʹ
 ѻ͑ΔΑ͏ʹͳΔมΘΓʹ
 ݁ߏɺ֮͑Δ͜ͱ͕ଟ͍

  108. େͯ͠༥௨΋ར͔ͳ͍

  109. ͡Ό͊ͳΜͰ4USFBNΛ
 ࢖͏ͷ͔ʁ

  110. 4USFBN"1*ͷ
 େ͖ͳ໨త͸
 4USFBNΛѻ͏͜ͱ

  111. None
  112. $PMMFDUJPO͸
 طʹ಺༰͕ܾ·͍ͬͯΔ
 σʔλ ʢ$PME4USFBNʣ

  113. ຊདྷͷ4USFBN͸
 ઈ͑ͣͯ͠
 ͔͠΋΋ͱͷਫʹ͋Βͣ

  114. 8FCͷϦΫΤετ΍
 ΩϡʔΠϯάॲཧͳͲ ಺༰΍্ݶ͕
 ܾ·ͬͯͳ͍΋ͷ
 ʢ)PU4USFBNʣ

  115. +BWBͷ4USFBN"1*͸
 جຊతʹ$PME4USFBNΛ
 ѻ͏ͨΊͷ΋ͷ

  116. ओઓ৔͸)PU4USFBN

  117. )PU4USFBNʹ
 ඞཁͳ΋ͷ

  118. ΢Οϯυ΢ؔ਺

  119. ྫɿ ਺ສͷηϯαʔ͔Β
 ૹ৴͞Εͨ৘ใΛ
 ड৴͠ͳ͕Β
 ूܭॲཧΛ͢Δ

  120. ड৴ॲཧͱฒߦͯ͠ɺ
 ਺݅ͣͭ·ͱΊͯूܭ͢Δɺ
 ਺ඵͣͭूܭ͢Δɺ
 ໰୊͕͋Ε͹Ξϥʔτ

  121. ͦΜͳ͜ͱ͕Ͱ͖Δ
 ΢Οϯυ΢ؔ਺͕ඞཁ

  122. +BWBͰଟগ͸ೖΔ͕
 ࠓͷͱ͜Ζ͸
 3Y+BWB΍3FBDUPSΛ࢖͏

  123. void monitorGauge(Flux<Double> input) { input.bufferTimeout(100, Duration.ofSeconds(10)) .subscribe(list -> { DoubleSummaryStatistics

    stats = list.stream() .mapToDouble(Double::doubleValue) .summaryStatistics(); if (stats.getMax() > maxThreshold) { alert(Level.WARNING); } if (stats.getAverage() > averageThreshold) { alert(Level.SEVERE); } }); } 3FBDUPSͷ"1*
  124. void monitorGauge(Flux<Double> input) { input.bufferTimeout(100, Duration.ofSeconds(10)) .subscribe(list -> { DoubleSummaryStatistics

    stats = list.stream() .mapToDouble(Double::doubleValue) .summaryStatistics(); if (stats.getMax() > maxThreshold) { alert(Level.WARNING); } if (stats.getAverage() > averageThreshold) { alert(Level.SEVERE); } }); } 3FBDUPSͷ"1* 100݅΋͘͠͸10ඵؒͷσʔλΛ
 ·ͱΊͯॲཧ͢Δ ʢूܭͯ͠ᮢ஋Λ௒͑ͨΒΞϥʔτʣ
  125. ϊϯϒϩοΩϯά"1*

  126. ྫɿ
 σʔλετΞ͔Β
 ສ݅ͷϨίʔυΛ
 औಘͨ͋͠ͱ
 ͦͷৄࡉσʔλΛ݅ͣͭ
 ສճऔಘ͢Δ

  127. ֓ཁσʔλΛऔಘ͔ͯ͠Β
 ৄࡉσʔλΛऔಘ͢Δ

  128. ͜Ε·Ͱ͸ಉظॲཧͰ
 σʔλϕʔεʹΞΫηε͢Δ
 Α͏ͳγεςϜΛͣͬͱ
 ࡞͖ͬͯ·ͨ͠

  129. 42-Λສճ
 ൃߦ͢Δඞཁ͕͋Ε͹
 ॱ൪ʹສճൃߦͯ͠
 ੑೳ໰୊͕ى͖͍ͯ·ͨ͠

  130. WebΞϓϦ DB 1ສճͷSQLͰ
 ੑೳ໰୊͕ൃੜ

  131. WebΞϓϦ DB ͪΐͬͱ޻෉ͯ͠
 গ͠ॏ͍ͨΫΤϦͰΧόʔ

  132. ϚΠΫϩαʔϏε ϚΠΫϩαʔϏε 1ສճͷαʔϏεݺͼग़͠

  133. ϚΠΫϩαʔϏε ϚΠΫϩαʔϏε ͜ͷ1ສճͷαʔϏεݺͼग़͠Λ
 ʮͰ͖Δ͚ͩಉ࣌ʹʯ
 ࣮ߦ͍ͨ͠

  134. ϊϯϒϩοΩϯάͳ
 ඇಉظ"1*ͱͯ͠
 ΍͸Γ
 3Y+BWBɺ3FBDUPSΛ࢖͏

  135. Mono<Map<Student, List<Score>>> map =
 studentService.fetchStudents("1年3組") .flatMap(student -> scoreService.fetchScore(2017, student.id)
 .collectList()

    .map(scores -> Tuples.of(student, scores))) .collectMap(Tuple2::getT1, Tuple2::getT2); // 出力 System.out.println(map.block());
 
 
 // 呼び出すAPI Flux<Student> fetchStudents(String className); Flux<Score> fetchScore(int year, int id) 3FBDUPSͷ"1*
  136. Mono<Map<Student, List<Score>>> map =
 studentService.fetchStudents("1年3組") .flatMap(student -> scoreService.fetchScore(2017, student.id)
 .collectList()

    .map(scores -> Tuples.of(student, scores))) .collectMap(Tuple2::getT1, Tuple2::getT2); // 出力 System.out.println(map.block());
 
 
 // 呼び出すAPI Flux<Student> fetchStudents(String className); Flux<Score> fetchScore(int year, int id) 3FBDUPSͷ"1* ʢৄࡉ͸ׂѪ͢Δ͚Ͳʣ
 APIݺͼग़͠ΛϊϯϒϩοΩϯά͔ͭ
 ඇಉظʹݺͼग़͢͜ͱͰ
 ॲཧશମͷ࣌ؒΛ୹ॖ
 ͔͠΋ར༻εϨου਺͕গͳ͍
  137. ͜͏͍͏΋ͷ͸ɺ͢΂ͯ
 4USFBN"1*ͷΑ͏ͳ
 ܗͰهड़͞ΕΔ͜ͱʹͳΔ

  138. ॲཧͷฒྻ౓Λ͋͛ͯ
 େྔσʔλ΍
 େྔϦΫΤετΛ
 ࡹ͘Α͏ͳ࣌୅

  139. ͦ͜ʹ޲͚ͨ४උͱͯ͠
 4USFBN"1*Λ
 शಘ͍ͯͩ͘͠͞

  140. -FU`T4UVEZ
 4USFBN"1*

  141. Ξϯέʔτޚڠྗ͓ئ͍͠·͢
 IUUQCJUMZKKVH

  142. +BWBຊ֨ೖ໳Λ
 ങͬͯͩ͘͞Δํ͸
 ͥͻ࿩͔͚͍ͯͩ͘͠͞