Class PagedQueryResponseBuilder

java.lang.Object
com.commercetools.api.models.common.PagedQueryResponseBuilder
All Implemented Interfaces:
Builder<PagedQueryResponse>

public class PagedQueryResponseBuilder extends Object implements Builder<PagedQueryResponse>
PagedQueryResponseBuilder
Example to create an instance using the builder pattern

     PagedQueryResponse pagedQueryResponse = PagedQueryResponse.builder()
             .limit(0.3)
             .offset(0.3)
             .count(0.3)
             .plusResults(resultsBuilder -> resultsBuilder)
             .build()
 
  • Constructor Details

    • PagedQueryResponseBuilder

      public PagedQueryResponseBuilder()
  • Method Details

    • limit

      public PagedQueryResponseBuilder limit(Long limit)

      Number of results requested.

      Parameters:
      limit - value to be set
      Returns:
      Builder
    • offset

      public PagedQueryResponseBuilder offset(Long offset)

      Number of elements skipped.

      Parameters:
      offset - value to be set
      Returns:
      Builder
    • count

      public PagedQueryResponseBuilder count(Long count)

      Actual number of results returned.

      Parameters:
      count - value to be set
      Returns:
      Builder
    • total

      Total number of results matching the query. This number is an estimation that is not strongly consistent. This field is returned by default. For improved performance, calculating this field can be deactivated by using the query parameter withTotal=false. When the results are filtered with a Query Predicate, total is subject to a limit.

      Parameters:
      total - value to be set
      Returns:
      Builder
    • results

      public PagedQueryResponseBuilder results(BaseResource... results)
      set values to the results
      Parameters:
      results - value to be set
      Returns:
      Builder
    • results

      public PagedQueryResponseBuilder results(List<BaseResource> results)
      set value to the results
      Parameters:
      results - value to be set
      Returns:
      Builder
    • plusResults

      public PagedQueryResponseBuilder plusResults(BaseResource... results)
      add values to the results
      Parameters:
      results - value to be set
      Returns:
      Builder
    • meta

      set the value to the meta
      Parameters:
      meta - value to be set
      Returns:
      Builder
    • getLimit

      public Long getLimit()

      Number of results requested.

      Returns:
      limit
    • getOffset

      public Long getOffset()

      Number of elements skipped.

      Returns:
      offset
    • getCount

      public Long getCount()

      Actual number of results returned.

      Returns:
      count
    • getTotal

      @Nullable public Long getTotal()

      Total number of results matching the query. This number is an estimation that is not strongly consistent. This field is returned by default. For improved performance, calculating this field can be deactivated by using the query parameter withTotal=false. When the results are filtered with a Query Predicate, total is subject to a limit.

      Returns:
      total
    • getResults

      public List<BaseResource> getResults()
      value of results}
      Returns:
      results
    • getMeta

      @Nullable public Object getMeta()
      value of meta}
      Returns:
      meta
    • build

      public PagedQueryResponse build()
      builds PagedQueryResponse with checking for non-null required values
      Specified by:
      build in interface Builder<PagedQueryResponse>
      Returns:
      PagedQueryResponse
    • buildUnchecked

      public PagedQueryResponse buildUnchecked()
      builds PagedQueryResponse without checking for non-null required values
      Returns:
      PagedQueryResponse
    • of

      public static PagedQueryResponseBuilder of()
      factory method for an instance of PagedQueryResponseBuilder
      Returns:
      builder
    • of

      public static PagedQueryResponseBuilder of(PagedQueryResponse template)
      create builder for PagedQueryResponse instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder