Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
antivoland committed Jul 17, 2023
1 parent 4747be3 commit c0589f7
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public Slice<? extends Segment> sliceFor(int lat) {
public Collection<? extends Segment> segments() {
return slices
.stream()
.flatMap(slice -> slice.segments().stream())
.filter(segment -> !segment.spots.isEmpty())
.map(Slice::nonEmptySegments)
.flatMap(Collection::stream)
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public NorthPoleSegment(NorthPoleSlice slice) {
@Override
public Collection<Segment> environment(double kmDelta) {
Collection<Segment> segments = new ArrayList<>();
slice.southernSlices(kmDelta).forEach(slice -> segments.addAll(slice.segments()));
slice.southernSlices(kmDelta).forEach(slice -> segments.addAll(slice.nonEmptySegments()));
return segments;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public SouthPoleSegment(SouthPoleSlice slice) {
@Override
public Collection<Segment> environment(double kmDelta) {
Collection<Segment> segments = new ArrayList<>();
slice.northernSlices(kmDelta).forEach(slice -> segments.addAll(slice.segments()));
slice.northernSlices(kmDelta).forEach(slice -> segments.addAll(slice.nonEmptySegments()));
return segments;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public NorthPoleSegment segmentFor(int lon) {
}

@Override
public Collection<NorthPoleSegment> segments() {
protected Collection<NorthPoleSegment> segments() {
return List.of(segment);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public RegularSegment segmentFor(int lon) {
}

@Override
public Collection<RegularSegment> segments() {
protected Collection<RegularSegment> segments() {
return segments.values();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ public final SEGMENT segmentFor(double lon) {

public abstract SEGMENT segmentFor(int lon);

public abstract Collection<SEGMENT> segments();
protected abstract Collection<SEGMENT> segments();

public final Collection<SEGMENT> nonEmptySegments() {
return segments()
.stream()
.filter(segment -> !segment.spots.isEmpty())
.toList();
}

public final Collection<Slice<?>> southernSlices(double kmDelta) {
if (type == SliceType.SOUTH_POLE) return List.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public SouthPoleSegment segmentFor(int lon) {
}

@Override
public Collection<SouthPoleSegment> segments() {
protected Collection<SouthPoleSegment> segments() {
return List.of(segment);
}

Expand Down

0 comments on commit c0589f7

Please sign in to comment.