Class ApiRequestConverter

java.lang.Object
com.totvs.tjf.api.jpa.ApiRequestConverter

public final class ApiRequestConverter extends Object
Converter for the TOTVS API Guideline request standards to Spring Data JPA domain to be used in the standards Spring Data repository.
Author:
Thiago A. de Souza Weber
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.springframework.data.domain.Pageable
    convert(com.totvs.tjf.api.context.request.ApiPageRequest apiPageRequest)
    Convert an ApiPageRequest to Pageable object.
    static org.springframework.data.domain.Pageable
    convert(com.totvs.tjf.api.context.request.ApiPageRequest apiPageRequest, com.totvs.tjf.api.context.request.ApiSortRequest apiSortRequest)
    Convert an ApiPageRequest and ApiSortRequest to Pageable object.
    static org.springframework.data.domain.Sort
    convert(com.totvs.tjf.api.context.request.ApiSortRequest apiSortRequest)
    Convert an ApiSortRequest to Pageable object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • convert

      public static org.springframework.data.domain.Pageable convert(@Nullable com.totvs.tjf.api.context.request.ApiPageRequest apiPageRequest)
      Convert an ApiPageRequest to Pageable object.

      In cases where the given ApiPageRequest is invalid, its is return the first page to be requested, with defaults specified by the TOTVS API Guideline.

      Note: Pageable is zero indexed, while ApiPageRequest is one indexed. Thus the page number provided by the ApiPageRequest is always decremented by 1 to be compatible with Pageable.

      Parameters:
      apiPageRequest - page specification by the TOTVS API Guideline
      Returns:
      a page to be requested
      See Also:
      • ApiPageRequest
      • Pageable
    • convert

      public static org.springframework.data.domain.Pageable convert(@Nullable com.totvs.tjf.api.context.request.ApiPageRequest apiPageRequest, @Nullable com.totvs.tjf.api.context.request.ApiSortRequest apiSortRequest)
      Convert an ApiPageRequest and ApiSortRequest to Pageable object.

      In cases where the given ApiPageRequest is invalid, its is return the first page to be requested, with defaults specified by the TOTVS API Guideline.

      Like the ApiPageRequest, when the ApiSortRequest is invalid, the page definition is create with unsorted instruction.

      Note: Pageable is zero indexed, while ApiPageRequest is one indexed. Thus the page number provided by the ApiPageRequest is always decremented by 1 to be compatible with Pageable.

      Parameters:
      apiPageRequest - page specification by the TOTVS API Guideline
      apiSortRequest - sort specification by the TOTVS API Guideline
      Returns:
      a page to be requested with possible sort instructions
      See Also:
      • ApiPageRequest
      • ApiSortRequest
      • Pageable
      • Sort
    • convert

      public static org.springframework.data.domain.Sort convert(@Nullable com.totvs.tjf.api.context.request.ApiSortRequest apiSortRequest)
      Convert an ApiSortRequest to Pageable object.

      In cases where the given ApiSortRequest is invalid, the page definition is create with unsorted instruction.

      Parameters:
      apiSortRequest - sort specification by the TOTVS API Guideline
      Returns:
      a sort instruction to be applied to the query
      See Also:
      • ApiSortRequest
      • Sort