{"id":331476,"date":"2022-04-04T15:00:50","date_gmt":"2022-04-04T15:00:50","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331476"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331476","title":{"rendered":"<span>Java Stream API \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/25e\/a20\/667\/25ea20667f1c0fbffb24e8d05345da96.png\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/25e\/a20\/667\/25ea20667f1c0fbffb24e8d05345da96.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0442\u0440\u0438\u043c\u044b \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0447\u0435\u043c-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0438 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430, \u043d\u043e \u0443 \u043d\u0438\u0445 \u0440\u0430\u0437\u043d\u043e\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0430 \u0441\u0442\u0440\u0438\u043c\u044b, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0434\u043b\u044f \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f. \u0421\u0442\u0440\u0438\u043c\u044b \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0439, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>User<\/code> \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"java\">import lombok.AllArgsConstructor; import lombok.Data; import lombok.ToString; @Data @AllArgsConstructor @ToString public class User {     private long id;     private String firstName;     private String lastName;     private int age;     private String nationality; }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <code>Sample<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"java\">import java.util.Arrays; import java.util.List; public class Sample {     private final List&lt;User> userList = Arrays.asList(             new User(1, \"Michael\", \"Robert\", 37, \"TR\"),             new User(2, \"Mary\", \"Patricia\", 11, \"EN\"),             new User(3, \"John\", \"Michael\", 7, \"FR\"),             new User(4, \"Jennifer\", \"Linda\", 77, \"TR\"),             new User(5, \"William\", \"Elizabeth\", 23, \"US\"),             new User(6, \"Sue\", \"Jackson\", 11, \"IT\"),             new User(7, \"Michael\", \"Tommy\", 37, \"EN\") );          public static void main(String... args) {         Sample sample = new Sample();     } }<\/code><\/pre>\n<p>1. \u041f\u0435\u0440\u0435\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 <code>userList<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>forEach()<\/code> \u0438 \u0432\u044b\u0432\u043e\u0434 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<pre><code class=\"java\">public static void main(String... args) {     Sample sample = new Sample();     sample.test1(); } private void test1() {     System.out.println(\"Test 1\");    userList.stream()            .forEach(System.out::println); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 1 User(id=1, firstName=Michael, lastName=Robert, age=37, nationality=TR) User(id=2, firstName=Mary, lastName=Patricia, age=11, nationality=EN) User(id=3, firstName=John, lastName=Michael, age=7, nationality=FR) User(id=4, firstName=Jennifer, lastName=Linda, age=77, nationality=TR) User(id=5, firstName=William, lastName=Elizabeth, age=23, nationality=US) User(id=6, firstName=Sue, lastName=Jackson, age=11, nationality=IT) User(id=7, firstName=Michael, lastName=Tommy, age=37, nationality=EN)<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a <code>userList<\/code> \u2014 \u044d\u0442\u043e <code>ArrayList<\/code>, \u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0445 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>2. \u041f\u0435\u0440\u0435\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0432\u044b\u0432\u043e\u0434 \u0438\u0445 \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<pre><code class=\"java\">private void test2() {      System.out.println(\"Test 2\");      userList.stream()            .map(u -> {               return new User(                       u.getId(),                       \"X \" + u.getFirstName(),                       \"Y \" + u.getLastName(),                       u.getAge() + 10),                       u.getNationality());             })            .collect(Collectors.toList())            .forEach(System.out::println); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 2 User(id=1, firstName=X Michael, lastName=Y Robert, age=47, nationality=TR) User(id=2, firstName=X Mary, lastName=Y Patricia, age=21, nationality=EN) User(id=3, firstName=X John, lastName=Y Michael, age=17, nationality=FR) User(id=4, firstName=X Jennifer, lastName=Y Linda, age=87, nationality=TR) User(id=5, firstName=X William, lastName=Y Elizabeth, age=33, nationality=US) User(id=6, firstName=X Sue, lastName=Y Jackson, age=21, nationality=IT) User(id=7, firstName=X Michael, lastName=Y Tommy, age=47, nationality=EN)<\/code><\/pre>\n<p>3. \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <code>age<\/code>.<\/p>\n<pre><code class=\"java\">private void test3() {     System.out.println(\"Test 3\");     userList.stream()             .sorted(Comparator.comparing(User::getAge))             .collect(Collectors.toList())             .forEach(System.out::println); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 3 User(id=3, firstName=John, lastName=Michael, age=7, nationality=FR) User(id=2, firstName=Mary, lastName=Patricia, age=11, nationality=EN) User(id=6, firstName=Sue, lastName=Jackson, age=11, nationality=IT) User(id=5, firstName=William, lastName=Elizabeth, age=23, nationality=US) User(id=1, firstName=Michael, lastName=Robert, age=37, nationality=TR) User(id=7, firstName=Michael, lastName=Tommy, age=37, nationality=EN) User(id=4, firstName=Jennifer, lastName=Linda, age=77, nationality=TR)<\/code><\/pre>\n<p>4. \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c: <code>age<\/code>, <code>firstName<\/code>, <code>lastName<\/code>.<\/p>\n<pre><code class=\"java\">private void test4() {     System.out.println(\"Test 4\");     userList.stream()             .sorted(Comparator.comparing(User::getAge)                 .thenComparing(User::getFirstName)                 .thenComparing(User::getLastName))             .collect(Collectors.toList())             .forEach(System.out::println); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 4 User(id=3, firstName=John, lastName=Michael, age=7, nationality=FR) User(id=2, firstName=Mary, lastName=Patricia, age=11, nationality=EN) User(id=6, firstName=Sue, lastName=Jackson, age=11, nationality=IT) User(id=5, firstName=William, lastName=Elizabeth, age=23, nationality=US) User(id=1, firstName=Michael, lastName=Robert, age=37, nationality=TR) User(id=7, firstName=Michael, lastName=Tommy, age=37, nationality=EN) User(id=4, firstName=Jennifer, lastName=Linda, age=77, nationality=TR)<\/code><\/pre>\n<p>5. \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 (<code>age<\/code>) \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b <code>firstName<\/code>.<\/p>\n<pre><code class=\"java\">private void test5() {     System.out.println(\"Test 5\");     double averageAge = userList.stream()         .mapToInt(User::getAge)         .summaryStatistics()         .getAverage();     System.out.print(\"averageAge: \" + averageAge);     int maxFirstNameLenght = userList.stream()         .mapToInt((value) -> {             return value.getFirstName().length();         })         .summaryStatistics()         .getMax();     System.out.println(\" maxFirstNameLenght: \" + maxFirstNameLenght); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>Test 5 averageAge: 29.0 maxFirstNameLenght: 8<\/code><\/pre>\n<p>6. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0443 \u0432\u0441\u0435\u0445 User \u0432\u043e\u0437\u0440\u0430\u0441\u0442 (<code>age<\/code>) \u0431\u043e\u043b\u044c\u0448\u0435 6.<\/p>\n<pre><code class=\"java\">private void test6() {     System.out.println(\"Test 6\");     boolean isAllAgesGreaterThan6 = userList.stream()                 .allMatch(user -> user.getAge() > 6);     System.out.println(\"isAllAgesGreaterThan6: \" +     isAllAgesGreaterThan6); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>Test 6 isAllAgesGreaterThan6: true<\/code><\/pre>\n<p>7. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u0442\u044c \u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0441 <code>firstName<\/code>, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0441 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 <code>S<\/code>.<\/p>\n<pre><code class=\"java\">private void test7() {     System.out.println(\"Test 7\");     boolean isFirstCharS = userList.stream()         .anyMatch(user -> user.getFirstName().charAt(0) == 'S');     System.out.println(\"isFirstCharS \" + isFirstCharS); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 7 isFirstCharS: true<\/code><\/pre>\n<p>8. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0432 \u0434\u0440\u0443\u0433\u0443\u044e.<\/p>\n<pre><code class=\"java\">private void test8() {     System.out.println(\"Test 8\");     List&lt;User> list = userList.stream()                 .collect(Collectors.toList());     Set&lt;User> set = userList.stream()                 .collect(Collectors.toSet());     List&lt;User> linkedList = userList.stream()                 .collect(Collectors.toCollection(LinkedList::new));     Map&lt;Long, User> map = userList.stream()                 .collect(Collectors.toMap(user -> user.getId(), user -> user)); }<\/code><\/pre>\n<p>9. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u043d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 (nationality).<\/p>\n<pre><code class=\"java\">private void test9() {     long countDifferentNationalites = userList.stream()                 .map(User::getNationality)                 .distinct()                 .count();     System.out.println(\"countDifferentNationalites: \" + countDifferentNationalites); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 9 countDifferentNationalites: 5<\/code><\/pre>\n<p>10. <code>User<\/code> \u0441\u0442\u0430\u0440\u0448\u0435 10 \u043b\u0435\u0442, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b <code>firstName<\/code> \u043d\u0435 \u0440\u0430\u0432\u0435\u043d <code>M<\/code>.<\/p>\n<pre><code class=\"java\">private void test10() {     System.out.println(\"Test 10\"); userList.stream()             .filter(p -> (p.getFirstName().charAt(0) != 'M'))             .filter(p -> (p.getAge() > 10))             .collect(Collectors.toList())             .forEach(System.out::println); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 10 User(id=4, firstName=Jennifer, lastName=Linda, age=77, nationality=TR) User(id=5, firstName=William, lastName=Elizabeth, age=23, nationality=US) User(id=6, firstName=Sue, lastName=Jackson, age=11, nationality=IT)<\/code><\/pre>\n<p>\u0420\u0435\u0437\u044e\u043c\u0438\u0440\u0443\u044f, Java Stream \u2014 \u044d\u0442\u043e \u043d\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0442\u0440\u0438\u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 (\u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445) \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a.<\/p>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/meteergin\/medium-java-streams\"><u>GitHub<\/u><\/a>.<\/p>\n<hr\/>\n<p>\u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0443\u0440\u043e\u043a \u00ab\u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0441\u043a\u0440\u044b\u0442\u0438\u0435, \u043f\u0435\u0440\u0435\u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044f\u00bb. \u0411\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 Java, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044f \u0438 \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u041f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0447\u0435\u0442\u044b\u0440\u044c\u043c\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u0435\u0449\u0451 \u0438 \u0441 \u043f\u044f\u0442\u044b\u043c. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f <a href=\"https:\/\/otus.pw\/zWOY\/\">\u0437\u0434\u0435\u0441\u044c.<\/a> <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/658999\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/658999\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0442\u0440\u0438\u043c\u044b \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0447\u0435\u043c-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0438 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430, \u043d\u043e \u0443 \u043d\u0438\u0445 \u0440\u0430\u0437\u043d\u043e\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0430 \u0441\u0442\u0440\u0438\u043c\u044b, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0434\u043b\u044f \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f. \u0421\u0442\u0440\u0438\u043c\u044b \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0439, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>User<\/code> \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"java\">import lombok.AllArgsConstructor; import lombok.Data; import lombok.ToString; @Data @AllArgsConstructor @ToString public class User {     private long id;     private String firstName;     private String lastName;     private int age;     private String nationality; }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <code>Sample<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"java\">import java.util.Arrays; import java.util.List; public class Sample {     private final List&lt;User> userList = Arrays.asList(             new User(1, \"Michael\", \"Robert\", 37, \"TR\"),             new User(2, \"Mary\", \"Patricia\", 11, \"EN\"),             new User(3, \"John\", \"Michael\", 7, \"FR\"),             new User(4, \"Jennifer\", \"Linda\", 77, \"TR\"),             new User(5, \"William\", \"Elizabeth\", 23, \"US\"),             new User(6, \"Sue\", \"Jackson\", 11, \"IT\"),             new User(7, \"Michael\", \"Tommy\", 37, \"EN\") );          public static void main(String... args) {         Sample sample = new Sample();     } }<\/code><\/pre>\n<p>1. \u041f\u0435\u0440\u0435\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 <code>userList<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>forEach()<\/code> \u0438 \u0432\u044b\u0432\u043e\u0434 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<pre><code class=\"java\">public static void main(String... args) {     Sample sample = new Sample();     sample.test1(); } private void test1() {     System.out.println(\"Test 1\");    userList.stream()            .forEach(System.out::println); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 1 User(id=1, firstName=Michael, lastName=Robert, age=37, nationality=TR) User(id=2, firstName=Mary, lastName=Patricia, age=11, nationality=EN) User(id=3, firstName=John, lastName=Michael, age=7, nationality=FR) User(id=4, firstName=Jennifer, lastName=Linda, age=77, nationality=TR) User(id=5, firstName=William, lastName=Elizabeth, age=23, nationality=US) User(id=6, firstName=Sue, lastName=Jackson, age=11, nationality=IT) User(id=7, firstName=Michael, lastName=Tommy, age=37, nationality=EN)<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a <code>userList<\/code> \u2014 \u044d\u0442\u043e <code>ArrayList<\/code>, \u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0445 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>2. \u041f\u0435\u0440\u0435\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0432\u044b\u0432\u043e\u0434 \u0438\u0445 \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<pre><code class=\"java\">private void test2() {      System.out.println(\"Test 2\");      userList.stream()            .map(u -> {               return new User(                       u.getId(),                       \"X \" + u.getFirstName(),                       \"Y \" + u.getLastName(),                       u.getAge() + 10),                       u.getNationality());             })            .collect(Collectors.toList())            .forEach(System.out::println); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 2 User(id=1, firstName=X Michael, lastName=Y Robert, age=47, nationality=TR) User(id=2, firstName=X Mary, lastName=Y Patricia, age=21, nationality=EN) User(id=3, firstName=X John, lastName=Y Michael, age=17, nationality=FR) User(id=4, firstName=X Jennifer, lastName=Y Linda, age=87, nationality=TR) User(id=5, firstName=X William, lastName=Y Elizabeth, age=33, nationality=US) User(id=6, firstName=X Sue, lastName=Y Jackson, age=21, nationality=IT) User(id=7, firstName=X Michael, lastName=Y Tommy, age=47, nationality=EN)<\/code><\/pre>\n<p>3. \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <code>age<\/code>.<\/p>\n<pre><code class=\"java\">private void test3() {     System.out.println(\"Test 3\");     userList.stream()             .sorted(Comparator.comparing(User::getAge))             .collect(Collectors.toList())             .forEach(System.out::println); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 3 User(id=3, firstName=John, lastName=Michael, age=7, nationality=FR) User(id=2, firstName=Mary, lastName=Patricia, age=11, nationality=EN) User(id=6, firstName=Sue, lastName=Jackson, age=11, nationality=IT) User(id=5, firstName=William, lastName=Elizabeth, age=23, nationality=US) User(id=1, firstName=Michael, lastName=Robert, age=37, nationality=TR) User(id=7, firstName=Michael, lastName=Tommy, age=37, nationality=EN) User(id=4, firstName=Jennifer, lastName=Linda, age=77, nationality=TR)<\/code><\/pre>\n<p>4. \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c: <code>age<\/code>, <code>firstName<\/code>, <code>lastName<\/code>.<\/p>\n<pre><code class=\"java\">private void test4() {     System.out.println(\"Test 4\");     userList.stream()             .sorted(Comparator.comparing(User::getAge)                 .thenComparing(User::getFirstName)                 .thenComparing(User::getLastName))             .collect(Collectors.toList())             .forEach(System.out::println); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 4 User(id=3, firstName=John, lastName=Michael, age=7, nationality=FR) User(id=2, firstName=Mary, lastName=Patricia, age=11, nationality=EN) User(id=6, firstName=Sue, lastName=Jackson, age=11, nationality=IT) User(id=5, firstName=William, lastName=Elizabeth, age=23, nationality=US) User(id=1, firstName=Michael, lastName=Robert, age=37, nationality=TR) User(id=7, firstName=Michael, lastName=Tommy, age=37, nationality=EN) User(id=4, firstName=Jennifer, lastName=Linda, age=77, nationality=TR)<\/code><\/pre>\n<p>5. \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 (<code>age<\/code>) \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b <code>firstName<\/code>.<\/p>\n<pre><code class=\"java\">private void test5() {     System.out.println(\"Test 5\");     double averageAge = userList.stream()         .mapToInt(User::getAge)         .summaryStatistics()         .getAverage();     System.out.print(\"averageAge: \" + averageAge);     int maxFirstNameLenght = userList.stream()         .mapToInt((value) -> {             return value.getFirstName().length();         })         .summaryStatistics()         .getMax();     System.out.println(\" maxFirstNameLenght: \" + maxFirstNameLenght); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>Test 5 averageAge: 29.0 maxFirstNameLenght: 8<\/code><\/pre>\n<p>6. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0443 \u0432\u0441\u0435\u0445 User \u0432\u043e\u0437\u0440\u0430\u0441\u0442 (<code>age<\/code>) \u0431\u043e\u043b\u044c\u0448\u0435 6.<\/p>\n<pre><code class=\"java\">private void test6() {     System.out.println(\"Test 6\");     boolean isAllAgesGreaterThan6 = userList.stream()                 .allMatch(user -> user.getAge() > 6);     System.out.println(\"isAllAgesGreaterThan6: \" +     isAllAgesGreaterThan6); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>Test 6 isAllAgesGreaterThan6: true<\/code><\/pre>\n<p>7. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u0442\u044c \u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0441 <code>firstName<\/code>, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0441 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 <code>S<\/code>.<\/p>\n<pre><code class=\"java\">private void test7() {     System.out.println(\"Test 7\");     boolean isFirstCharS = userList.stream()         .anyMatch(user -> user.getFirstName().charAt(0) == 'S');     System.out.println(\"isFirstCharS \" + isFirstCharS); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 7 isFirstCharS: true<\/code><\/pre>\n<p>8. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0432 \u0434\u0440\u0443\u0433\u0443\u044e.<\/p>\n<pre><code class=\"java\">private void test8() {     System.out.println(\"Test 8\");     List&lt;User> list = userList.stream()                 .collect(Collectors.toList());     Set&lt;User> set = userList.stream()                 .collect(Collectors.toSet());     List&lt;User> linkedList = userList.stream()                 .collect(Collectors.toCollection(LinkedList::new));     Map&lt;Long, User> map = userList.stream()                 .collect(Collectors.toMap(user -> user.getId(), user -> user)); }<\/code><\/pre>\n<p>9. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u043d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 (nationality).<\/p>\n<pre><code class=\"java\">private void test9() {     long countDifferentNationalites = userList.stream()                 .map(User::getNationality)                 .distinct()                 .count();     System.out.println(\"countDifferentNationalites: \" + countDifferentNationalites); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 9 countDifferentNationalites: 5<\/code><\/pre>\n<p>10. <code>User<\/code> \u0441\u0442\u0430\u0440\u0448\u0435 10 \u043b\u0435\u0442, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b <code>firstName<\/code> \u043d\u0435 \u0440\u0430\u0432\u0435\u043d <code>M<\/code>.<\/p>\n<pre><code class=\"java\">private void test10() {     System.out.println(\"Test 10\"); userList.stream()             .filter(p -> (p.getFirstName().charAt(0) != 'M'))             .filter(p -> (p.getAge() > 10))             .collect(Collectors.toList())             .forEach(System.out::println); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"java\">Test 10 User(id=4, firstName=Jennifer, lastName=Linda, age=77, nationality=TR) User(id=5, firstName=William, lastName=Elizabeth, age=23, nationality=US) User(id=6, firstName=Sue, lastName=Jackson, age=11, nationality=IT)<\/code><\/pre>\n<p>\u0420\u0435\u0437\u044e\u043c\u0438\u0440\u0443\u044f, Java Stream \u2014 \u044d\u0442\u043e \u043d\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0442\u0440\u0438\u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 (\u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445) \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a.<\/p>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/meteergin\/medium-java-streams\"><u>GitHub<\/u><\/a>.<\/p>\n<hr\/>\n<p>\u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0443\u0440\u043e\u043a \u00ab\u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0441\u043a\u0440\u044b\u0442\u0438\u0435, \u043f\u0435\u0440\u0435\u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044f\u00bb. \u0411\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 Java, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044f \u0438 \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u041f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0447\u0435\u0442\u044b\u0440\u044c\u043c\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u0435\u0449\u0451 \u0438 \u0441 \u043f\u044f\u0442\u044b\u043c. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f <a href=\"https:\/\/otus.pw\/zWOY\/\">\u0437\u0434\u0435\u0441\u044c.<\/a> <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/658999\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/658999\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-331476","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331476"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331476\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}