-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
22 additions
and
36 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
stream-merger/src/main/java/com/josdem/kata/CustomInputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.josdem.kata; | ||
|
||
public record CustomInputStream(int id) implements Comparable<CustomInputStream> { | ||
|
||
@Override | ||
public int compareTo(CustomInputStream that) { | ||
return Integer.compare(this.id, that.id); | ||
} | ||
} |
11 changes: 3 additions & 8 deletions
11
stream-merger/src/main/java/com/josdem/kata/CustomOutputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
package com.josdem.kata; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.logging.Logger; | ||
|
||
public class CustomOutputStream { | ||
private final List<Integer> list = new ArrayList<>(); | ||
private final Logger log = Logger.getLogger(this.getClass().getName()); | ||
|
||
void storeValue(int value) { | ||
list.add(value); | ||
} | ||
|
||
public List<Integer> getList() { | ||
return list; | ||
log.info("value: " + value); | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
stream-merger/src/main/java/com/josdem/kata/CustomStream.java
This file was deleted.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
stream-merger/src/main/java/com/josdem/kata/StreamMerger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package com.josdem.kata; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
|
||
public record StreamMerger(Set<CustomStream> streams) { | ||
public record StreamMerger(Set<CustomInputStream> streams) { | ||
|
||
public Set<CustomStream> mergeInto(CustomOutputStream stream) { | ||
TreeSet<CustomStream> treeSet = new TreeSet<>(streams); | ||
treeSet.forEach(item -> stream.storeValue(item.getId())); | ||
public Set<CustomInputStream> mergeInto(CustomOutputStream stream) { | ||
TreeSet<CustomInputStream> treeSet = new TreeSet<>(streams); | ||
treeSet.forEach(item -> stream.storeValue(item.id())); | ||
return treeSet; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters