Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collection;

import java.util.Optional;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.stream.Collector;
import java.util.stream.Stream;

public class Main {
    public static <E> Collector<Optional<E>, Collection<E>, Stream<E>> filterEmpty() {
        return Collector.of(ConcurrentLinkedQueue::new, (q, oe) -> oe.ifPresent(q::add), (q1, q2) -> {
            q1.addAll(q2);
            return q1;
        }, Collection::stream);
    }
}