Object ServiceBase.Companion
-
- All Implemented Interfaces:
public class ServiceBase.Companion
-
-
Field Summary
Fields Modifier and Type Field Description public final static ServiceBase.CompanionINSTANCE
-
Method Summary
Modifier and Type Method Description final StringencodeUrlIfRequested(String value, String encodingType)URL-encodes value using urlEncodeIgnoreSlashes when encodingType is "url"; returns the value unchanged otherwise (including when value is null).final List<String>encodeUrlIfRequested(List<String> values, String encodingType)URL-encodes each element of values when encodingType is "url"; returns the list unchanged otherwise.final <T extends Any> List<T>encodeUrlIfRequested(List<T> items, String encodingType, Function1<T, T> transform)Applies transform to each element of items when encodingType is "url"; returns the list unchanged otherwise.final <T extends Any, R extends Comparable<R>> List<T>filterBy(List<T> contents, Function1<T, R> selector, R compareTo)final <T extends Any> List<T>filterBy(List<T> contents, Function1<T, String> selector, List<String> prefixes)final <T extends Any> List<String>collapseCommonPrefixes(String queryPrefix, String delimiter, List<T> contents, Function1<T, String> function)Collapse all elements with keys starting with some prefix up to the given delimiter into one prefix entry. -
-
Method Detail
-
encodeUrlIfRequested
final String encodeUrlIfRequested(String value, String encodingType)
URL-encodes value using urlEncodeIgnoreSlashes when encodingType is
"url"; returns the value unchanged otherwise (including when value is null).
-
encodeUrlIfRequested
final List<String> encodeUrlIfRequested(List<String> values, String encodingType)
URL-encodes each element of values when encodingType is
"url"; returns the list unchanged otherwise.
-
encodeUrlIfRequested
final <T extends Any> List<T> encodeUrlIfRequested(List<T> items, String encodingType, Function1<T, T> transform)
Applies transform to each element of items when encodingType is
"url"; returns the list unchanged otherwise. Use when URL-encoding is applied to a field inside a domain object rather than a plain String.
-
filterBy
final <T extends Any, R extends Comparable<R>> List<T> filterBy(List<T> contents, Function1<T, R> selector, R compareTo)
-
filterBy
final <T extends Any> List<T> filterBy(List<T> contents, Function1<T, String> selector, List<String> prefixes)
-
collapseCommonPrefixes
final <T extends Any> List<String> collapseCommonPrefixes(String queryPrefix, String delimiter, List<T> contents, Function1<T, String> function)
Collapse all elements with keys starting with some prefix up to the given delimiter into one prefix entry. Collapsed elements are removed from the contents list.
- Parameters:
queryPrefix- the key prefix as specified in the list requestdelimiter- the delimiter used to separate a prefix from the rest of the object namecontents- the list of contents to use for collapsing the prefixesfunction- the function to apply on a content to extract the value to collapse the prefixes on
-
-
-
-