Java Stream Operation findStreamAmongst(Class clazz, Collection instances)

Here you can find the source of findStreamAmongst(Class clazz, Collection instances)

Description

find Stream Amongst

License

Apache License

Declaration

private static <T> Stream<T> findStreamAmongst(Class<T> clazz, Collection<?> instances) 

Method Source Code

//package com.java2s;
/*// w w w .j a  v a 2 s  .  c o  m
 * Copyright Terracotta, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.Collection;

import java.util.stream.Stream;

public class Main {
    private static <T> Stream<T> findStreamAmongst(Class<T> clazz, Collection<?> instances) {
        return instances.stream().filter(clazz::isInstance).map(clazz::cast);
    }
}

Related

  1. factorStream(long number)
  2. filterInstances(Stream stream, Class clazz)
  3. filterType(Stream stream, Class type)
  4. findLast(Stream s)
  5. findLastOf(Stream stream)
  6. firstValue(Stream stream)
  7. flatOptionals(Stream> list)
  8. flattenFeatureStreamToMap( Stream>>> stream)
  9. gcd(IntStream numbers)