class StreamUtilities {

    @SuppressWarnings("unchecked")
    public static <T> Stream<T> filterDowncast(Stream<?> input, Class<T> type)
    {
        return input.filter(obj -> type.isInstance(obj)).map(obj -> (T)obj);
    }

    private  StreamUtilities();

}