Package io.rocketbase.commons.util
Class QueryParamParser
java.lang.Object
io.rocketbase.commons.util.QueryParamParser
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BooleanparseBoolean(String value, Boolean defaultValue) static BooleanparseBoolean(org.springframework.util.MultiValueMap<String, String> params, String key, Boolean defaultValue) static <T extends Enum>
Tstatic <T extends Enum>
TparseEnum(org.springframework.util.MultiValueMap<String, String> params, String key, Class<T> clazz, T defaultValue) parseEnumSet(org.springframework.util.MultiValueMap<String, String> params, String key, Class<T> clazz, Set<T> defaultValue) static InstantparseInstant(String value, Instant defaultValue) static InstantparseInstant(org.springframework.util.MultiValueMap<String, String> params, String key, Instant defaultValue) static IntegerparseInteger(String value, Integer defaultValue) static IntegerparseInteger(org.springframework.util.MultiValueMap<String, String> params, String key, Integer defaultValue) parseKeyValue(String key, org.springframework.util.MultiValueMap<String, String> params) static LocalDateparseLocalDate(String value, LocalDate defaultValue) static LocalDateparseLocalDate(org.springframework.util.MultiValueMap<String, String> params, String key, LocalDate defaultValue) static LocalDateTimeparseLocalDateTime(String value, LocalDateTime defaultValue) static LocalDateTimeparseLocalDateTime(org.springframework.util.MultiValueMap<String, String> params, String key, LocalDateTime defaultValue) static LocalTimeparseLocalTime(String value, LocalTime defaultValue) static LocalTimeparseLocalTime(org.springframework.util.MultiValueMap<String, String> params, String key, LocalTime defaultValue) static Longstatic LongparseLong(org.springframework.util.MultiValueMap<String, String> params, String key, Long defaultValue) static org.springframework.data.domain.PageableparsePageRequest(org.springframework.util.MultiValueMap<String, String> params) parse page, size and sort from requeststatic org.springframework.data.domain.PageableparsePageRequest(org.springframework.util.MultiValueMap<String, String> params, String pageSizeKey, String pageKey, String sortKey, org.springframework.data.domain.Sort defaultSort, int defaultPageSize, int maxPageSize) parse page, size and sort from requeststatic org.springframework.data.domain.PageableparsePageRequest(org.springframework.util.MultiValueMap<String, String> params, org.springframework.data.domain.Sort defaultSort, int defaultPageSize, int maxPageSize) parse page, size and sort from requeststatic org.springframework.data.domain.Sortparse sort and build correctSortorPageablestatic org.springframework.data.domain.SortparseSort(org.springframework.util.MultiValueMap<String, String> params, String key, org.springframework.data.domain.Sort defaultSort) parse sort and build correctSortorPageablestatic StringparseString(org.springframework.util.MultiValueMap<String, String> params, String key)
-
Field Details
-
DEFAULT_DATE_FORMATTERS
-
-
Constructor Details
-
QueryParamParser
public QueryParamParser()
-
-
Method Details
-
parsePageRequest
public static org.springframework.data.domain.Pageable parsePageRequest(org.springframework.util.MultiValueMap<String, String> params) parse page, size and sort from request- Parameters:
params- MultiValueMap that contains all query params of request- Returns:
- a filled
PageRequest
-
parsePageRequest
public static org.springframework.data.domain.Pageable parsePageRequest(org.springframework.util.MultiValueMap<String, String> params, org.springframework.data.domain.Sort defaultSort, int defaultPageSize, int maxPageSize) parse page, size and sort from request- Parameters:
params- MultiValueMap that contains all query params of requestdefaultSort- sort that should get used in case of not filled parameterdefaultPageSize- in case the pageSize is not set - which value to takemaxPageSize- maximum size of pageSize to limit the response size- Returns:
- a filled
PageRequest
-
parsePageRequest
public static org.springframework.data.domain.Pageable parsePageRequest(org.springframework.util.MultiValueMap<String, String> params, String pageSizeKey, String pageKey, String sortKey, org.springframework.data.domain.Sort defaultSort, int defaultPageSize, int maxPageSize) parse page, size and sort from request- Parameters:
params- MultiValueMap that contains all query params of requestpageSizeKey- queryParam of current size of page to querypageKey- queryParam of current page to querysortKey- queryParam of sort to querydefaultSort- sort that should get used in case of not filled parameterdefaultPageSize- in case the pageSize is not set - which value to takemaxPageSize- maximum size of pageSize to limit the response size- Returns:
- a filled
PageRequest
-
parseSort
public static org.springframework.data.domain.Sort parseSort(org.springframework.util.MultiValueMap<String, String> params, String key) parse sort and build correctSortorPageable- Parameters:
params- MultiValueMap that contains all query params of requestkey- name of sort parameter in uri- Returns:
- an unsorted Sort in case of empty param or filled one
-
parseSort
public static org.springframework.data.domain.Sort parseSort(org.springframework.util.MultiValueMap<String, String> params, String key, org.springframework.data.domain.Sort defaultSort) parse sort and build correctSortorPageable- Parameters:
params- MultiValueMap that contains all query params of requestkey- name of sort parameter in uridefaultSort- sort that should get used in case of not filled parameter- Returns:
- defaultSort in case of empty param or filled one
-
parseString
-
parseInteger
-
parseInteger
-
parseLong
-
parseLong
-
parseBoolean
-
parseBoolean
-
parseLocalDate
-
parseLocalDate
-
parseLocalTime
-
parseLocalTime
-
parseLocalDateTime
public static LocalDateTime parseLocalDateTime(org.springframework.util.MultiValueMap<String, String> params, String key, LocalDateTime defaultValue) -
parseLocalDateTime
-
parseInstant
-
parseInstant
-
parseEnum
-
parseEnum
-
parseEnumSet
-
parseKeyValue
-