Template for a Query String parameter.
| 33 | |
| 34 | /** Template for a Query String parameter. */ |
| 35 | public final class QueryTemplate { |
| 36 | |
| 37 | private static final String UNDEF = "undef"; |
| 38 | private List<Template> values; |
| 39 | private final Template name; |
| 40 | private final CollectionFormat collectionFormat; |
| 41 | private boolean pure = false; |
| 42 | |
| 43 | /** |
| 44 | * Create a new Query Template. |
| 45 | * |
| 46 | * @param name of the query parameter. |
| 47 | * @param values in the template. |
| 48 | * @param charset for the template. |
| 49 | * @return a QueryTemplate. |
| 50 | */ |
| 51 | public static QueryTemplate create(String name, Iterable<String> values, Charset charset) { |
| 52 | return create(name, values, charset, CollectionFormat.EXPLODED, true); |
| 53 | } |
| 54 | |
| 55 | public static QueryTemplate create( |
| 56 | String name, Iterable<String> values, Charset charset, CollectionFormat collectionFormat) { |
| 57 | return create(name, values, charset, collectionFormat, true); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Create a new Query Template. |
| 62 | * |
| 63 | * @param name of the query parameter. |
| 64 | * @param values in the template. |
| 65 | * @param charset for the template. |
| 66 | * @param collectionFormat to use. |
| 67 | * @param decodeSlash if slash characters should be decoded |
| 68 | * @return a QueryTemplate |
| 69 | */ |
| 70 | public static QueryTemplate create( |
| 71 | String name, |
| 72 | Iterable<String> values, |
| 73 | Charset charset, |
| 74 | CollectionFormat collectionFormat, |
| 75 | boolean decodeSlash) { |
| 76 | if (Util.isBlank(name)) { |
| 77 | throw new IllegalArgumentException("name is required."); |
| 78 | } |
| 79 | |
| 80 | if (values == null) { |
| 81 | throw new IllegalArgumentException("values are required"); |
| 82 | } |
| 83 | |
| 84 | /* remove all empty values from the array */ |
| 85 | Collection<String> remaining = |
| 86 | StreamSupport.stream(values.spliterator(), false) |
| 87 | .filter(Util::isNotBlank) |
| 88 | .collect(Collectors.toList()); |
| 89 | |
| 90 | return new QueryTemplate(name, remaining, charset, collectionFormat, decodeSlash); |
| 91 | } |
| 92 |
nothing calls this directly
no outgoing calls
no test coverage detected