Skip to content

Commit

Permalink
Gjør sonar glad (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
tendestad authored Mar 28, 2022
1 parent b7ec70b commit 095674b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/no/nav/fpsak/tidsserie/LocalDateTimeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ public <T, R> LocalDateTimeline<R> combine(final LocalDateTimeline<T> other, fin
long nesteFomEpochDay = startdatoIterator.nextEpochDay();
if (combinationStyle.accept(harLhs, harRhs)) {
LocalDateInterval periode = new LocalDateInterval(fom, LocalDate.ofEpochDay(nesteFomEpochDay - 1));
LocalDateSegment<V> tilpassetLhsSegment = harLhs ? splittVedDelvisOverlapp(this.segmentSplitter, lhs, periode) : null;
LocalDateSegment<T> tilpassetRhsSegment = harRhs ? splittVedDelvisOverlapp(other.segmentSplitter, rhs, periode) : null;
LocalDateSegment<V> tilpassetLhsSegment = tilpassSegment(harLhs, lhs, periode, this.segmentSplitter);
LocalDateSegment<T> tilpassetRhsSegment = tilpassSegment(harRhs, rhs, periode, other.segmentSplitter);
LocalDateSegment<R> nyVerdi = combinator.combine(periode, tilpassetLhsSegment, tilpassetRhsSegment);
if (nyVerdi != null) {
combinedSegmenter.add(nyVerdi);
Expand All @@ -261,14 +261,16 @@ public <T, R> LocalDateTimeline<R> combine(final LocalDateTimeline<T> other, fin
return new LocalDateTimeline<>(combinedSegmenter);
}

private static <X> LocalDateSegment<X> splittVedDelvisOverlapp(SegmentSplitter<X> segmentSplitter, LocalDateSegment<X> segment, LocalDateInterval ønsketIntervall) {
if (segment == null || segment.getLocalDateInterval().equals(ønsketIntervall)) {
private static <X> LocalDateSegment<X> tilpassSegment(boolean harSegment, LocalDateSegment<X> segment, LocalDateInterval ønsketIntervall, SegmentSplitter<X> segmentSplitter) {
if (!harSegment) {
return null;
}
if (segment.getLocalDateInterval().equals(ønsketIntervall)){
return segment;
}
return segmentSplitter.apply(ønsketIntervall, segment);
}


/**
* Fikser opp tidslinjen slik at tilgrensende intervaller med equal verdi får et sammenhengende intervall. Nyttig
* for å 'redusere' tidslinjen ned til enkleste form før lagring etc.
Expand Down

0 comments on commit 095674b

Please sign in to comment.