Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.stream.Collector;
import java.util.stream.Collector.Characteristics;
import com.google.common.collect.ImmutableList;

public class Main {
    public static <E> Collector<E, ImmutableList.Builder<E>, ImmutableList<E>> collectToImmutableList() {
        return Collector.of(
                ImmutableList::builder, ImmutableList.Builder::add, (ImmutableList.Builder<E> builder1,
                        ImmutableList.Builder<E> builder2) -> builder1.addAll(builder2.build()),
                ImmutableList.Builder::build, Characteristics.CONCURRENT);
    }
}