Package io.rocketbase.commons.util
Class QueryParamParser
- java.lang.Object
-
- io.rocketbase.commons.util.QueryParamParser
-
public final class QueryParamParser extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static List<DateTimeFormatter>DEFAULT_DATE_FORMATTERS
-
Constructor Summary
Constructors Constructor Description QueryParamParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BooleanparseBoolean(String value, Boolean defaultValue)static BooleanparseBoolean(org.springframework.util.MultiValueMap<String,String> params, String key, Boolean defaultValue)static <T extends Enum>
TparseEnum(String value, Class<T> clazz, T defaultValue)static <T extends Enum>
TparseEnum(org.springframework.util.MultiValueMap<String,String> params, String key, Class<T> clazz, T defaultValue)static <T extends Enum>
Set<T>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)static Map<String,String>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 LongparseLong(String value, Long defaultValue)static 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.SortparseSort(org.springframework.util.MultiValueMap<String,String> params, String key)parse 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 Detail
-
DEFAULT_DATE_FORMATTERS
public static List<DateTimeFormatter> DEFAULT_DATE_FORMATTERS
-
-
Method Detail
-
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
public static String parseString(org.springframework.util.MultiValueMap<String,String> params, String key)
-
parseInteger
public static Integer parseInteger(org.springframework.util.MultiValueMap<String,String> params, String key, Integer defaultValue)
-
parseLong
public static Long parseLong(org.springframework.util.MultiValueMap<String,String> params, String key, Long defaultValue)
-
parseBoolean
public static Boolean parseBoolean(org.springframework.util.MultiValueMap<String,String> params, String key, Boolean defaultValue)
-
parseLocalDate
public static LocalDate parseLocalDate(org.springframework.util.MultiValueMap<String,String> params, String key, LocalDate defaultValue)
-
parseLocalTime
public static LocalTime parseLocalTime(org.springframework.util.MultiValueMap<String,String> params, String key, LocalTime defaultValue)
-
parseLocalDateTime
public static LocalDateTime parseLocalDateTime(org.springframework.util.MultiValueMap<String,String> params, String key, LocalDateTime defaultValue)
-
parseLocalDateTime
public static LocalDateTime parseLocalDateTime(String value, LocalDateTime defaultValue)
-
parseInstant
public static Instant parseInstant(org.springframework.util.MultiValueMap<String,String> params, String key, Instant defaultValue)
-
parseEnum
public static <T extends Enum> T parseEnum(org.springframework.util.MultiValueMap<String,String> params, String key, Class<T> clazz, T defaultValue)
-
parseEnumSet
public static <T extends Enum> Set<T> parseEnumSet(org.springframework.util.MultiValueMap<String,String> params, String key, Class<T> clazz, Set<T> defaultValue)
-
-