com.memority.domino.shared.api.PageResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of domino-api Show documentation
Show all versions of domino-api Show documentation
This artifact provides the API classes that are necessary to implement synchronization configuration Rules on the Memority IM platform.
/*
* Copyright (c) 2016-2023 Memority. All Rights Reserved.
*
* This file is part of Memority Domino API , a Memority project.
*
* This file is released under the Memority Public Artifacts End-User License Agreement,
* see
* Unauthorized copying of this file, via any medium is strictly prohibited.
*/
package com.memority.domino.shared.api;
import java.util.List;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Setter;
import lombok.experimental.Accessors;
/**
* The result of a paged search.
*/
@Data @Accessors(chain = true)
public class PageResult {
/**
* The paged objects returned by the search.
*/
private final List content;
/**
* Whether all results have been returned or more results shall be fetched. If {@code getContent().size() < getSize()}
* then {@code complete} should be {@code true}.
*/
private final boolean complete;
/**
* See {@link PageRequest#getPagingToken()}
*/
private final Object pagingToken;
/**
* The total number of elements, negative if unknown.
*/
@Setter(AccessLevel.PRIVATE)
private long totalElements = -1;
/**
* The number of remaining elements, negative if unknown.
*/
@Setter(AccessLevel.PRIVATE)
private long remainingElements = -1;
private PageResult(List content, boolean complete, Object pagingToken) {
this.content = content;
this.complete = complete;
this.pagingToken = pagingToken;
}
private static PageResult of(List content, boolean complete, Object pagingToken) {
return new PageResult<>(content, complete, pagingToken);
}
/**
* Return the page content, indicating that the search is complete.
*
* @param content a page of remote objects
* @param the object's type
* @return the page result
*/
public static PageResult complete(List content) {
return of(content, true, null);
}
/**
* Return the page content, indicating that the search is not complete; there are some entries left.
*
* @param content a page of remote objects
* @param the object's type
* @return the page result
*/
public static PageResult partial(List content) {
return partial(content, null);
}
/**
* Return the page content, indicating that the search is not complete; there are some entries left.
*
* @param content a page of remote objects
* @param pagingToken an opaque token returned by the application to keep track of the search progress,
* to be sent in the next page request, see {@link PageRequest#pagingToken}
* @param the object's type
* @return the page result
*/
public static PageResult partial(List content, Object pagingToken) {
return of(content, false, pagingToken);
}
public PageResult totalElements(long totalElements) {
this.totalElements = totalElements;
return this;
}
public PageResult remainingElements(long remainingElements) {
this.remainingElements = remainingElements;
return this;
}
}