
com.sappenin.utils.rest.v2.model.paging.PagableQueryParams Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-utils2 Show documentation
Show all versions of rest-utils2 Show documentation
Utilities, Helpers, and base-classes for assisting in server-side REST API implementations written in
Java.
The newest version!
package com.sappenin.utils.rest.v2.model.paging;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.sappenin.utils.rest.v2.model.paging.Sort.SortDirection;
/**
* A container for holding an offset, limit, and optional sort parameter that indicates the sorted field and a sort
* direction.
*/
@RequiredArgsConstructor
@Data(staticConstructor = "of")
public class PagableQueryParams
{
@NonNull
private final Optional optOffset;
@NonNull
private final Optional optLimit;
@NonNull
private final Optional optSortDirection;
// Callers may set this to true to expand all expandable sub-resources in a pagable collection. For more customized
// expando operations, clients should implement their own functionality.
@NonNull
private final Optional optExpand;
/**
* No-args Constructor.
*/
public PagableQueryParams()
{
this.optOffset = Optional.absent();
this.optLimit = Optional.absent();
this.optSortDirection = Optional.absent();
this.optExpand = Optional.absent();
}
public PagableQueryParams(final Optional optOffset, final Optional optLimit)
{
Preconditions.checkNotNull(optOffset);
Preconditions.checkNotNull(optLimit);
this.optOffset = optOffset;
this.optLimit = optLimit;
this.optSortDirection = Optional.absent();
this.optExpand = Optional.absent();
}
/**
* Helper method to create an empty {@link PagableQueryParams}.
*
* @return
*/
public static PagableQueryParams of()
{
return new PagableQueryParams(Optional. absent(), Optional. absent());
}
/**
* Helper method to create an empty {@link PagableQueryParams}.
*
* @return
*/
public static PagableQueryParams of(final Optional optOffset, final Optional optLimit)
{
return new PagableQueryParams(optOffset, optLimit, Optional. absent(),
Optional. absent());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy