java.util.StreamImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dragome-js-jre Show documentation
Show all versions of dragome-js-jre Show documentation
Dragome SDK module: js-jre
The newest version!
/*
* Copyright (c) 2011-2014 Fernando Petrola
*
* 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.
*/
package java.util;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Optional;
import java.util.Spliterator;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.BinaryOperator;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;
import java.util.stream.Collector;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;
public class StreamImpl implements Stream, Consumer
{
protected Consumer downstream;
protected StreamImpl topStream;
private Collection items;
public StreamImpl()
{
topStream= this;
}
public StreamImpl(StreamImpl upstream)
{
topStream= upstream.topStream;
upstream.downstream= this;
}
public StreamImpl(Collection items)
{
this();
this.items= items;
}
public Iterator iterator()
{
return items.iterator();
}
public Spliterator spliterator()
{
// TODO Auto-generated method stub
return null;
}
public boolean isParallel()
{
// TODO Auto-generated method stub
return false;
}
public Stream sequential()
{
// TODO Auto-generated method stub
return null;
}
public Stream parallel()
{
// TODO Auto-generated method stub
return null;
}
public Stream unordered()
{
// TODO Auto-generated method stub
return null;
}
public Stream onClose(Runnable closeHandler)
{
// TODO Auto-generated method stub
return null;
}
public void close()
{
// TODO Auto-generated method stub
}
public Stream filter(Predicate super T> predicate)
{
return new StreamImpl((StreamImpl) this)
{
public void accept(T t)
{
if (predicate.test(t))
downstream.accept(t);
}
};
}
public Stream map(Function super T, ? extends R> mapper)
{
return new StreamImpl((StreamImpl) this)
{
public void accept(T t)
{
downstream.accept((T) mapper.apply(t));
}
};
}
public IntStream mapToInt(ToIntFunction super T> mapper)
{
// TODO Auto-generated method stub
return null;
}
public LongStream mapToLong(ToLongFunction super T> mapper)
{
// TODO Auto-generated method stub
return null;
}
public DoubleStream mapToDouble(ToDoubleFunction super T> mapper)
{
// TODO Auto-generated method stub
return null;
}
public Stream flatMap(Function super T, ? extends Stream extends R>> mapper)
{
// TODO Auto-generated method stub
return null;
}
public IntStream flatMapToInt(Function super T, ? extends IntStream> mapper)
{
// TODO Auto-generated method stub
return null;
}
public LongStream flatMapToLong(Function super T, ? extends LongStream> mapper)
{
// TODO Auto-generated method stub
return null;
}
public DoubleStream flatMapToDouble(Function super T, ? extends DoubleStream> mapper)
{
// TODO Auto-generated method stub
return null;
}
public Stream distinct()
{
// TODO Auto-generated method stub
return null;
}
public Stream sorted()
{
// TODO Auto-generated method stub
return null;
}
public Stream sorted(Comparator super T> comparator)
{
// TODO Auto-generated method stub
return null;
}
public Stream peek(Consumer super T> action)
{
// TODO Auto-generated method stub
return null;
}
public Stream limit(long maxSize)
{
// TODO Auto-generated method stub
return null;
}
public Stream skip(long n)
{
// TODO Auto-generated method stub
return null;
}
public void forEach(Consumer super T> action)
{
new StreamImpl((StreamImpl) this)
{
public void accept(T t)
{
action.accept(t);
}
};
for (Iterator iterator= topStream.iterator(); iterator.hasNext();)
{
T type= (T) iterator.next();
topStream.accept((C) type);
}
}
public void forEachOrdered(Consumer super T> action)
{
// TODO Auto-generated method stub
}
public Object[] toArray()
{
// TODO Auto-generated method stub
return null;
}
public A[] toArray(IntFunction generator)
{
// TODO Auto-generated method stub
return null;
}
public T reduce(T identity, BinaryOperator accumulator)
{
// TODO Auto-generated method stub
return null;
}
public Optional reduce(BinaryOperator accumulator)
{
// TODO Auto-generated method stub
return null;
}
public U reduce(U identity, BiFunction accumulator, BinaryOperator combiner)
{
// TODO Auto-generated method stub
return null;
}
public R collect(Supplier supplier, BiConsumer accumulator, BiConsumer combiner)
{
// TODO Auto-generated method stub
return null;
}
public R collect(Collector super T, A, R> collector)
{
forEach(v -> collector.accumulator().accept(null, v));
return collector.finisher().apply(null);
}
public Optional min(Comparator super T> comparator)
{
// TODO Auto-generated method stub
return null;
}
public Optional max(Comparator super T> comparator)
{
// TODO Auto-generated method stub
return null;
}
public long count()
{
int[] counter= new int[1];
counter[0]= 0;
forEach(new Consumer()
{
public void accept(T t)
{
counter[0]++;
}
});
return counter[0];
}
public boolean anyMatch(Predicate super T> predicate)
{
// TODO Auto-generated method stub
return false;
}
public boolean allMatch(Predicate super T> predicate)
{
// TODO Auto-generated method stub
return false;
}
public boolean noneMatch(Predicate super T> predicate)
{
// TODO Auto-generated method stub
return false;
}
public Optional findFirst()
{
// TODO Auto-generated method stub
return null;
}
public Optional findAny()
{
// TODO Auto-generated method stub
return null;
}
@Override
public void accept(C t)
{
downstream.accept(t);
}
}