Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
josdem committed Apr 27, 2024
2 parents 3f04374 + c1ccbed commit 2c7ce26
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions stream-merger/StreamMerger.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,16 @@
import java.util.Set;
import java.util.TreeSet;

class InputStream implements Comparable<InputStream> {
private Integer streamId;
private Integer nextValue;

public InputStream(Integer streamId, Integer nextValue) {
this.streamId = streamId;
this.nextValue = nextValue;
}

public Integer getStreamId() {
return streamId;
}

public Integer getNextValue() {
return nextValue;
}
record InputStream(Integer streamId, Integer nextValue) implements Comparable<InputStream> {

@Override
public int compareTo(InputStream that) {
return this.getStreamId().compareTo(that.getStreamId());
return this.streamId().compareTo(that.streamId());
}

@Override
public String toString() {
return this.getStreamId().toString();
return this.streamId().toString();
}
}

Expand All @@ -47,7 +32,7 @@ public class StreamMerger {

void mergeInto(OutputStream stream) {
TreeSet<InputStream> treeSet = new TreeSet<>(streams);
treeSet.forEach(item -> stream.emitValue(item.getStreamId()));
treeSet.forEach(item -> stream.emitValue(item.streamId()));
}

public static void main(String[] args) {
Expand Down

0 comments on commit 2c7ce26

Please sign in to comment.