<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Loading

      Java 8 Collectors.collectingAndThen()

      JDK源碼

      java.util.stream.Collectors#collectingAndThen方法的作用是將Collector的結果在執行一個額外的finisher轉換操作,其源碼如下:

      /**
       * Adapts a {@code Collector} to perform an additional finishing
       * transformation.  For example, one could adapt the {@link #toList()}
       * collector to always produce an immutable list with:
       * <pre>{@code
       *     List<String> people
       *         = people.stream().collect(collectingAndThen(toList(), Collections::unmodifiableList));
       * }</pre>
       *
       * @param <T> the type of the input elements
       * @param <A> intermediate accumulation type of the downstream collector
       * @param <R> result type of the downstream collector
       * @param <RR> result type of the resulting collector
       * @param downstream a collector
       * @param finisher a function to be applied to the final result of the downstream collector
       * @return a collector which performs the action of the downstream collector,
       * followed by an additional finishing step
       */
      public static<T, A, R, RR> Collector<T, A, RR> collectingAndThen(Collector<T, A, R> downstream, Function<R, RR> finisher) {
          Set<Collector.Characteristics> characteristics = downstream.characteristics();
          if (characteristics.contains(Collector.Characteristics.IDENTITY_FINISH)) {
              if (characteristics.size() == 1) {
                  characteristics = Collectors.CH_NOID;
              } else {
                  characteristics = EnumSet.copyOf(characteristics);
                  characteristics.remove(Collector.Characteristics.IDENTITY_FINISH);
                  characteristics = Collections.unmodifiableSet(characteristics);
              }
          }
          return new CollectorImpl<>(downstream.supplier(),
                  downstream.accumulator(),
                  downstream.combiner(),
                  downstream.finisher().andThen(finisher),
                  characteristics);
      }
      
      • T:輸入元素的類型
      • A:下游Collector的中間堆積類型
      • R:下游Collector的結果類型
      • RR:結果Collector的結果類型

      參數:此方法接受下面列出的兩個參數

      • downstream: Collector的一個實例,可以使用任何Collector
      • finisher: 類型是Function,該函數將應用于下游Collector的最終結果

      返回值:返回一個執行下游Collector動作的Collector,然后在finisher函數的幫助下執行附加的轉換步驟。

      范例:

      創建不可變集合

      // Create an Immutable List
      List<String> lt = Stream.of("GEEKS", "For", "GEEKS").collect(Collectors.collectingAndThen(Collectors.toList(), Collections::<String>unmodifiableList));
      
      // Create an Immutable Set
      Set<String> st = Stream.of("GEEKS", "FOR", "GEEKS").collect(Collectors.collectingAndThen(Collectors.toSet(), Collections::<String>unmodifiableSet));
      
      // Create an Immutable Map
      Map<String, String> mp = Stream.of(new String[][] {{ "1", "Geeks" }, { "2", "For" }, { "3", "Geeks" }})
                .collect(Collectors.collectingAndThen(Collectors.toMap(p -> p[0], p -> p[1]), Collections::<String, String>unmodifiableMap));
      

      對象去重:

      List<Xxx> distinctList = rowList.stream()
              .collect(Collectors.collectingAndThen(
                      Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(obj -> String.join("-", obj.getA(), obj.getB(), obj.getC())))),
                      ArrayList::new
              ));
      
      Map<Integer, BigDecimal> mongthValuePair = map.computeIfAbsent(year, ArrayList::new)
              .stream().collect(Collectors.toMap(A::getMonth, A::getValue));
      

      參考文章:

      posted @ 2021-08-09 19:52  dai.sp  閱讀(5421)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 日本乱一区二区三区在线| 樱花草视频www日本韩国| 亚洲综合精品一区二区三区| 忘忧草影视| 丁香五月婷激情综合第九色 | 在线涩涩免费观看国产精品| 国产综合一区二区三区麻豆| 亚洲成人高清av在线| 野花社区在线观看视频| 在线观看亚洲欧美日本| 国产小嫩模无套中出视频| 国产不卡免费一区二区| 国产成人精品2021欧美日韩| 狠狠躁夜夜躁人人爽天天古典| 性欧美VIDEOFREE高清大喷水| 极品蜜桃臀一区二区av| 一本久久a久久精品综合| 人妻系列中文字幕精品| 激情五月天自拍偷拍视频| 久久青青草原亚洲AV无码麻豆| 亚洲无线码中文字幕在线| 亚洲成在人线AV品善网好看| 2019亚洲午夜无码天堂| 亚洲中文字幕无码久久2020| 国产精品久久久午夜夜伦鲁鲁 | 国产亚洲无线码一区二区| 国产无套乱子伦精彩是白视频| 国产女人喷潮视频免费| 被黑人巨大一区二区三区| 亚洲日本国产精品一区| 国产精品自在拍在线播放| 久久精品国产亚洲av麻豆软件| 沅陵县| 成人国产精品日本在线观看| 日韩福利视频导航| 精品午夜福利在线视在亚洲| 天堂久久天堂av色综合| 国产欧美日韩精品第二区| 人妻体内射精一区二区三四| 国产成人无码免费视频在线| 定兴县|