Skip to content

Commit e7d5c7c

Browse files
update to using the primitive integer type in resolveLimitWithExtra
Adjust collecting in fhir util to use helper functions to aid readability of code
1 parent 475bc17 commit e7d5c7c

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

apps/bfd-server-ng/src/main/java/gov/cms/bfd/server/ng/input/ClaimSearchCriteria.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public Integer resolveLimit() {
5151
* @param extra extra to add for pagination checking than the requested limit
5252
* @return limit
5353
*/
54-
public Integer resolveLimitWithExtra(Integer extra) {
55-
return limit.orElse(5000) + (extra == null ? 0 : extra);
54+
public Integer resolveLimitWithExtra(int extra) {
55+
return limit.orElse(5000) + extra;
5656
}
5757

5858
/**

apps/bfd-server-ng/src/main/java/gov/cms/bfd/server/ng/util/FhirUtil.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,11 @@ record Page(List<Bundle.BundleEntryComponent> items, boolean hasMore) {}
183183
// limits the stream to only return the requested limit
184184
(list, count) ->
185185
new Page(
186-
limit.isPresent() && count > limit.get().longValue()
187-
? list.subList(0, limit.get())
188-
: list,
189-
limit.isPresent() && count > limit.get().longValue())));
186+
trimEntriesToLimit(list, count, limit),
187+
determineHasMore(count, limit)
188+
)
189+
)
190+
);
190191

191192
var bundle = new Bundle().setEntry(page.items());
192193

@@ -197,6 +198,17 @@ record Page(List<Bundle.BundleEntryComponent> items, boolean hasMore) {}
197198
return bundle;
198199
}
199200

201+
private static List<Bundle.BundleEntryComponent> trimEntriesToLimit(List<Bundle.BundleEntryComponent> entries,long count,Optional<Integer> limit){
202+
if(limit.isPresent() && count > limit.get().longValue()) {
203+
return entries.subList(0, limit.get());
204+
}
205+
return entries;
206+
}
207+
208+
private static boolean determineHasMore(long count,Optional<Integer> limit){
209+
return limit.isPresent() && count > limit.get().longValue();
210+
}
211+
200212
/**
201213
* Returns a default bundle.
202214
*

0 commit comments

Comments
 (0)