File tree 6 files changed +42
-7
lines changed
main/java/com/jnape/palatable/lambda
com/jnape/palatable/lambda/iteration
6 files changed +42
-7
lines changed Original file line number Diff line number Diff line change 1
1
package com .jnape .palatable .lambda .functions .builtin .fn1 ;
2
2
3
3
import com .jnape .palatable .lambda .functions .Fn1 ;
4
- import com .jnape .palatable .lambda .iteration .CyclicIterator ;
4
+ import com .jnape .palatable .lambda .iteration .CyclicIterable ;
5
5
6
6
import static java .util .Arrays .asList ;
7
7
@@ -20,7 +20,7 @@ private Cycle() {
20
20
21
21
@ Override
22
22
public Iterable <A > apply (Iterable <A > as ) {
23
- return () -> new CyclicIterator <>(as . iterator () );
23
+ return new CyclicIterable <>(as );
24
24
}
25
25
26
26
@ SuppressWarnings ("unchecked" )
Original file line number Diff line number Diff line change
1
+ package com .jnape .palatable .lambda .iteration ;
2
+
3
+ import java .util .Iterator ;
4
+
5
+ public final class CyclicIterable <A > implements Iterable <A > {
6
+ private final Iterable <A > as ;
7
+
8
+ public CyclicIterable (Iterable <A > as ) {
9
+ while (as instanceof CyclicIterable ) {
10
+ as = ((CyclicIterable <A >) as ).as ;
11
+ }
12
+ this .as = as ;
13
+ }
14
+
15
+ @ Override
16
+ public Iterator <A > iterator () {
17
+ return new CyclicIterator <>(as .iterator ());
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ package com .jnape .palatable .lambda .iteration ;
2
+
3
+ import com .jnape .palatable .lambda .functions .Fn1 ;
4
+ import com .jnape .palatable .traitor .annotations .TestTraits ;
5
+ import com .jnape .palatable .traitor .runners .Traits ;
6
+ import org .junit .runner .RunWith ;
7
+ import testsupport .traits .Deforesting ;
8
+
9
+ @ RunWith (Traits .class )
10
+ public class CyclicIterableTest {
11
+
12
+ @ TestTraits ({Deforesting .class })
13
+ public Fn1 <Iterable <?>, Iterable <?>> testSubject () {
14
+ return CyclicIterable ::new ;
15
+ }
16
+ }
Original file line number Diff line number Diff line change 4
4
import com .jnape .palatable .traitor .annotations .TestTraits ;
5
5
import com .jnape .palatable .traitor .runners .Traits ;
6
6
import org .junit .runner .RunWith ;
7
- import testsupport .traits .NestingStackSafety ;
7
+ import testsupport .traits .Deforesting ;
8
8
9
9
@ RunWith (Traits .class )
10
10
public class DroppingIterableTest {
11
11
12
- @ TestTraits ({NestingStackSafety .class })
12
+ @ TestTraits ({Deforesting .class })
13
13
public Fn1 <Iterable <?>, Iterable <?>> testSubject () {
14
14
return x -> new DroppingIterable <>(1 , x );
15
15
}
Original file line number Diff line number Diff line change 4
4
import com .jnape .palatable .traitor .annotations .TestTraits ;
5
5
import com .jnape .palatable .traitor .runners .Traits ;
6
6
import org .junit .runner .RunWith ;
7
- import testsupport .traits .NestingStackSafety ;
7
+ import testsupport .traits .Deforesting ;
8
8
9
9
@ RunWith (Traits .class )
10
10
public class SnocIterableTest {
11
11
12
- @ TestTraits ({NestingStackSafety .class })
12
+ @ TestTraits ({Deforesting .class })
13
13
public Fn1 <Iterable <Object >, Iterable <Object >> testSubject () {
14
14
return xs -> new SnocIterable <>(1 , xs );
15
15
}
Original file line number Diff line number Diff line change 6
6
import static com .jnape .palatable .lambda .functions .builtin .fn1 .Repeat .repeat ;
7
7
import static com .jnape .palatable .lambda .functions .builtin .fn3 .Times .times ;
8
8
9
- public final class NestingStackSafety implements Trait <Fn1 <Iterable <?>, Iterable <?>>> {
9
+ public final class Deforesting implements Trait <Fn1 <Iterable <?>, Iterable <?>>> {
10
10
11
11
@ Override
12
12
public void test (Fn1 <Iterable <?>, Iterable <?>> fn ) {
You can’t perform that action at this time.
0 commit comments