Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ffe42af

Browse files
committed
Merge pull request jhusain#3 from benjchristensen/answers
ComposableListSolution
2 parents 7cec31e + c128fb7 commit ffe42af

15 files changed

+1778
-373
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<dependency>
1717
<groupId>junit</groupId>
1818
<artifactId>junit</artifactId>
19-
<version>3.8.1</version>
19+
<version>4.11</version>
2020
<scope>test</scope>
2121
</dependency>
2222
</dependencies>

src/main/java/learnrxjava/ComposableList.java renamed to src/main/java/learnrxjava/ComposableListExercises.java

Lines changed: 239 additions & 372 deletions
Large diffs are not rendered by default.

src/main/java/learnrxjava/ComposableListSolution.java

Lines changed: 1154 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package learnrxjava.types;
2+
3+
public class Bookmark {
4+
@Override
5+
public String toString() {
6+
return "Bookmark{" + "id=" + id + ", offset=" + offset + '}';
7+
}
8+
9+
public int id;
10+
public int offset;
11+
12+
public Bookmark(int id, int offset) {
13+
this.id = id;
14+
this.offset = offset;
15+
}
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package learnrxjava.types;
2+
3+
public class BookmarkRow {
4+
public int videoId;
5+
public int bookmarkId;
6+
7+
public BookmarkRow(int videoId, int bookmarkId) {
8+
this.videoId = videoId;
9+
this.bookmarkId = bookmarkId;
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package learnrxjava.types;
2+
3+
public class BoxArt {
4+
public int width;
5+
public int height;
6+
public String url;
7+
8+
public BoxArt(int width, int height, String url) {
9+
this.width = width;
10+
this.height = height;
11+
this.url = url;
12+
}
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package learnrxjava.types;
2+
3+
public class BoxArtRow {
4+
5+
public int videoId;
6+
public int width;
7+
public int height;
8+
public String url;
9+
10+
public BoxArtRow(int videoId, int width, int height, String url) {
11+
this.videoId = videoId;
12+
this.width = width;
13+
this.height = height;
14+
this.url = url;
15+
}
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package learnrxjava.types;
2+
3+
import java.util.function.BiFunction;
4+
import java.util.function.Consumer;
5+
import java.util.function.Function;
6+
import java.util.function.Predicate;
7+
8+
public interface ComposableList<T> extends Iterable<T> {
9+
10+
public <R> ComposableList<R> map(Function<T, R> projectionFunction);
11+
12+
public ComposableList<T> filter(Predicate<T> predicateFunction);
13+
14+
public <R> ComposableList<R> concatMap(Function<T, ComposableList<R>> projectionFunctionThatReturnsList);
15+
16+
public ComposableList<T> reduce(BiFunction<T, T, T> combiner);
17+
18+
public <R> ComposableList<R> reduce(R initialValue, BiFunction<R, T, R> combiner);
19+
20+
public int size();
21+
22+
public void forEach(Consumer<? super T> action);
23+
24+
public T get(int index);
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package learnrxjava.types;
2+
3+
public class InterestingMoment {
4+
@Override
5+
public String toString() {
6+
return "InterestingMoment{" + "type=" + type + ", time=" + time + '}';
7+
}
8+
9+
public String type;
10+
public int time;
11+
12+
public InterestingMoment(String type, int time) {
13+
this.type = type;
14+
this.time = time;
15+
}
16+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package learnrxjava.types;
2+
3+
import java.util.HashMap;
4+
5+
// Custom JSON type
6+
public class JSON extends HashMap<String, Object> {
7+
}

0 commit comments

Comments
 (0)