in commons/src/main/java/com/epam/eco/schemacatalog/fts/SearchResult.java [85:116]
public SearchResult(
@JsonProperty("content") List<T> content,
@JsonProperty("pageNumber") int pageNumber,
@JsonProperty("pageSize") int pageSize,
@JsonProperty("totalElements") long totalElements,
@JsonProperty("maxResultWindow") long maxResultWindow,
@JsonProperty("aggregations") Map<String, Map<String, Long>> aggregations) {
Validate.notNull(content, "Content is null");
Validate.isTrue(pageNumber >= 0, "Page Number is invalid");
Validate.isTrue(pageSize > 0, "Page Size is invalid");
Validate.isTrue(totalElements >= 0, "Number of Total Elements is invalid");
Validate.isTrue(maxResultWindow > 0, "Max Result Window is invalid");
Validate.isTrue(
pageNumber * pageSize + content.size() <= maxResultWindow,
"Result window is too large");
this.content = Collections.unmodifiableList(new ArrayList<>(content));
this.pageNumber = pageNumber;
this.pageSize = pageSize;
this.totalElements = totalElements;
this.maxResultWindow = maxResultWindow;
this.aggregations =
aggregations != null ?
aggregations.entrySet().stream().
collect(
Collectors.collectingAndThen(
Collectors.toMap(
Map.Entry::getKey,
e -> Collections.unmodifiableMap(new HashMap<>(e.getValue()))),
Collections::unmodifiableMap)) :
Collections.emptyMap();
}