Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardcombinators min+max for comparable + concatLists + setOps #116

Merged
merged 7 commits into from
Oct 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Concat lists
jolarsen committed Sep 24, 2022

Verified

This commit was signed with the committer’s verified signature.
mwpreston Mike Preston
commit f093f57de45c5df5d9f52e93a7557a960d1c9c0a
16 changes: 16 additions & 0 deletions src/main/java/no/nav/fpsak/tidsserie/StandardCombinators.java
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Stream;

import no.nav.fpsak.tidsserie.LocalDateTimeline.JoinStyle;

@@ -170,6 +171,21 @@ public static <V extends Comparable<? super V>> LocalDateSegment<V> max(LocalDat
return lhs == null ? new LocalDateSegment<>(dateInterval, rhs.getValue()) : new LocalDateSegment<>(dateInterval, lhs.getValue());
}

/**
* Basic combinator som slår sammen Liste-verdier til en liste
*/
public static <V> LocalDateSegment<List<V>> concatToList(LocalDateInterval dateInterval,
LocalDateSegment<List<V>> lhs,
LocalDateSegment<List<V>> rhs) {
if (lhs != null && rhs != null) {
return new LocalDateSegment<>(dateInterval, Stream.concat(lhs.getValue().stream(), rhs.getValue().stream()).toList());
} else if (lhs == null && rhs == null) {
return null;
}
return lhs == null ? new LocalDateSegment<>(dateInterval, rhs.getValue()) : new LocalDateSegment<>(dateInterval, lhs.getValue());
}



@SuppressWarnings("unchecked")
private static <L extends Number, R extends Number> L sum(L lhs, R rhs) {