Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.lambda.spliterators

File TakeWhile.java

 

Coverage histogram

../../../../img/srcFileCovDistChart5.png
36% of files have more coverage

Code metrics

4
9
6
1
49
40
8
0.89
1.5
6
1.33

Classes

Class Line # Actions
TakeWhile 8 9 8
0.4736842247.4%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    package io.sunshower.lambda.spliterators;
2   
3    import java.util.Comparator;
4    import java.util.Spliterator;
5    import java.util.function.Consumer;
6    import java.util.function.Predicate;
7   
 
8    public class TakeWhile<T> implements Spliterator<T> {
9   
10    private final Spliterator<T> source;
11    private final Predicate<T> condition;
12    private boolean conditionHolds = true;
13   
 
14  3 toggle public TakeWhile(Spliterator<T> source, Predicate<T> condition) {
15  3 this.source = source;
16  3 this.condition = condition;
17    }
18   
 
19  25 toggle @Override
20    public boolean tryAdvance(Consumer<? super T> action) {
21  25 return conditionHolds
22    && source.tryAdvance(
23    e -> {
24  ? if (conditionHolds = condition.test(e)) {
25  20 action.accept(e);
26    }
27    });
28    }
29   
 
30  0 toggle @Override
31    public Spliterator<T> trySplit() {
32  0 return null;
33    }
34   
 
35  0 toggle @Override
36    public long estimateSize() {
37  0 return conditionHolds ? source.estimateSize() : 0;
38    }
39   
 
40  6 toggle @Override
41    public int characteristics() {
42  6 return source.characteristics() & ~Spliterator.SIZED;
43    }
44   
 
45  0 toggle @Override
46    public Comparator<? super T> getComparator() {
47  0 return source.getComparator();
48    }
49    }