001
002package com.commercetools.api.client;
003
004import java.net.URI;
005import java.time.Duration;
006import java.util.ArrayList;
007import java.util.Collection;
008import java.util.List;
009import java.util.concurrent.CompletableFuture;
010import java.util.function.Function;
011import java.util.function.Supplier;
012import java.util.stream.Collectors;
013
014import io.vrap.rmf.base.client.*;
015import io.vrap.rmf.base.client.utils.Generated;
016
017import org.apache.commons.lang3.builder.EqualsBuilder;
018import org.apache.commons.lang3.builder.HashCodeBuilder;
019
020/**
021 *
022 *
023 * <hr>
024 * <div class=code-example>
025 * <pre><code class='java'>{@code
026 *   CompletableFuture<ApiHttpResponse<com.commercetools.api.models.business_unit.BusinessUnitPagedQueryResponse>> result = apiRoot
027 *            .withProjectKey("{projectKey}")
028 *            .businessUnits()
029 *            .get()
030 *            .execute()
031 * }</code></pre>
032 * </div>
033 */
034@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
035public class ByProjectKeyBusinessUnitsGet extends
036        ApiMethod<ByProjectKeyBusinessUnitsGet, com.commercetools.api.models.business_unit.BusinessUnitPagedQueryResponse>
037        implements ByProjectKeyBusinessUnitsGetMixin,
038        com.commercetools.api.client.ExpandableTrait<ByProjectKeyBusinessUnitsGet>,
039        com.commercetools.api.client.SortableTrait<ByProjectKeyBusinessUnitsGet>,
040        com.commercetools.api.client.PagingTrait<ByProjectKeyBusinessUnitsGet>,
041        com.commercetools.api.client.QueryTrait<ByProjectKeyBusinessUnitsGet>,
042        com.commercetools.api.client.ErrorableTrait<ByProjectKeyBusinessUnitsGet>,
043        com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyBusinessUnitsGet> {
044
045    private String projectKey;
046
047    public ByProjectKeyBusinessUnitsGet(final ApiHttpClient apiHttpClient, String projectKey) {
048        super(apiHttpClient);
049        this.projectKey = projectKey;
050    }
051
052    public ByProjectKeyBusinessUnitsGet(ByProjectKeyBusinessUnitsGet t) {
053        super(t);
054        this.projectKey = t.projectKey;
055    }
056
057    @Override
058    protected ApiHttpRequest buildHttpRequest() {
059        List<String> params = new ArrayList<>(getQueryParamUriStrings());
060        String httpRequestPath = String.format("%s/business-units", this.projectKey);
061        if (!params.isEmpty()) {
062            httpRequestPath += "?" + String.join("&", params);
063        }
064        return new ApiHttpRequest(ApiHttpMethod.GET, URI.create(httpRequestPath), getHeaders(), null);
065    }
066
067    @Override
068    public ApiHttpResponse<com.commercetools.api.models.business_unit.BusinessUnitPagedQueryResponse> executeBlocking(
069            final ApiHttpClient client, final Duration timeout) {
070        return executeBlocking(client, timeout,
071            com.commercetools.api.models.business_unit.BusinessUnitPagedQueryResponse.class);
072    }
073
074    @Override
075    public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.business_unit.BusinessUnitPagedQueryResponse>> execute(
076            final ApiHttpClient client) {
077        return execute(client, com.commercetools.api.models.business_unit.BusinessUnitPagedQueryResponse.class);
078    }
079
080    public String getProjectKey() {
081        return this.projectKey;
082    }
083
084    public List<String> getExpand() {
085        return this.getQueryParam("expand");
086    }
087
088    public List<String> getSort() {
089        return this.getQueryParam("sort");
090    }
091
092    public List<String> getLimit() {
093        return this.getQueryParam("limit");
094    }
095
096    public List<String> getOffset() {
097        return this.getQueryParam("offset");
098    }
099
100    public List<String> getWithTotal() {
101        return this.getQueryParam("withTotal");
102    }
103
104    public List<String> getWhere() {
105        return this.getQueryParam("where");
106    }
107
108    public void setProjectKey(final String projectKey) {
109        this.projectKey = projectKey;
110    }
111
112    /**
113     * set expand with the specified value
114     * @param expand value to be set
115     * @param <TValue> value type
116     * @return ByProjectKeyBusinessUnitsGet
117     */
118    public <TValue> ByProjectKeyBusinessUnitsGet withExpand(final TValue expand) {
119        return copy().withQueryParam("expand", expand);
120    }
121
122    /**
123     * add additional expand query parameter
124     * @param expand value to be added
125     * @param <TValue> value type
126     * @return ByProjectKeyBusinessUnitsGet
127     */
128    public <TValue> ByProjectKeyBusinessUnitsGet addExpand(final TValue expand) {
129        return copy().addQueryParam("expand", expand);
130    }
131
132    /**
133     * set expand with the specified value
134     * @param supplier supplier for the value to be set
135     * @return ByProjectKeyBusinessUnitsGet
136     */
137    public ByProjectKeyBusinessUnitsGet withExpand(final Supplier<String> supplier) {
138        return copy().withQueryParam("expand", supplier.get());
139    }
140
141    /**
142     * add additional expand query parameter
143     * @param supplier supplier for the value to be added
144     * @return ByProjectKeyBusinessUnitsGet
145     */
146    public ByProjectKeyBusinessUnitsGet addExpand(final Supplier<String> supplier) {
147        return copy().addQueryParam("expand", supplier.get());
148    }
149
150    /**
151     * set expand with the specified value
152     * @param op builder for the value to be set
153     * @return ByProjectKeyBusinessUnitsGet
154     */
155    public ByProjectKeyBusinessUnitsGet withExpand(final Function<StringBuilder, StringBuilder> op) {
156        return copy().withQueryParam("expand", op.apply(new StringBuilder()));
157    }
158
159    /**
160     * add additional expand query parameter
161     * @param op builder for the value to be added
162     * @return ByProjectKeyBusinessUnitsGet
163     */
164    public ByProjectKeyBusinessUnitsGet addExpand(final Function<StringBuilder, StringBuilder> op) {
165        return copy().addQueryParam("expand", op.apply(new StringBuilder()));
166    }
167
168    /**
169     * set expand with the specified values
170     * @param expand values to be set
171     * @param <TValue> value type
172     * @return ByProjectKeyBusinessUnitsGet
173     */
174    public <TValue> ByProjectKeyBusinessUnitsGet withExpand(final Collection<TValue> expand) {
175        return copy().withoutQueryParam("expand")
176                .addQueryParams(
177                    expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
178    }
179
180    /**
181     * add additional expand query parameters
182     * @param expand values to be added
183     * @param <TValue> value type
184     * @return ByProjectKeyBusinessUnitsGet
185     */
186    public <TValue> ByProjectKeyBusinessUnitsGet addExpand(final Collection<TValue> expand) {
187        return copy().addQueryParams(
188            expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
189    }
190
191    /**
192     * set sort with the specified value
193     * @param sort value to be set
194     * @param <TValue> value type
195     * @return ByProjectKeyBusinessUnitsGet
196     */
197    public <TValue> ByProjectKeyBusinessUnitsGet withSort(final TValue sort) {
198        return copy().withQueryParam("sort", sort);
199    }
200
201    /**
202     * add additional sort query parameter
203     * @param sort value to be added
204     * @param <TValue> value type
205     * @return ByProjectKeyBusinessUnitsGet
206     */
207    public <TValue> ByProjectKeyBusinessUnitsGet addSort(final TValue sort) {
208        return copy().addQueryParam("sort", sort);
209    }
210
211    /**
212     * set sort with the specified value
213     * @param supplier supplier for the value to be set
214     * @return ByProjectKeyBusinessUnitsGet
215     */
216    public ByProjectKeyBusinessUnitsGet withSort(final Supplier<String> supplier) {
217        return copy().withQueryParam("sort", supplier.get());
218    }
219
220    /**
221     * add additional sort query parameter
222     * @param supplier supplier for the value to be added
223     * @return ByProjectKeyBusinessUnitsGet
224     */
225    public ByProjectKeyBusinessUnitsGet addSort(final Supplier<String> supplier) {
226        return copy().addQueryParam("sort", supplier.get());
227    }
228
229    /**
230     * set sort with the specified value
231     * @param op builder for the value to be set
232     * @return ByProjectKeyBusinessUnitsGet
233     */
234    public ByProjectKeyBusinessUnitsGet withSort(final Function<StringBuilder, StringBuilder> op) {
235        return copy().withQueryParam("sort", op.apply(new StringBuilder()));
236    }
237
238    /**
239     * add additional sort query parameter
240     * @param op builder for the value to be added
241     * @return ByProjectKeyBusinessUnitsGet
242     */
243    public ByProjectKeyBusinessUnitsGet addSort(final Function<StringBuilder, StringBuilder> op) {
244        return copy().addQueryParam("sort", op.apply(new StringBuilder()));
245    }
246
247    /**
248     * set sort with the specified values
249     * @param sort values to be set
250     * @param <TValue> value type
251     * @return ByProjectKeyBusinessUnitsGet
252     */
253    public <TValue> ByProjectKeyBusinessUnitsGet withSort(final Collection<TValue> sort) {
254        return copy().withoutQueryParam("sort")
255                .addQueryParams(
256                    sort.stream().map(s -> new ParamEntry<>("sort", s.toString())).collect(Collectors.toList()));
257    }
258
259    /**
260     * add additional sort query parameters
261     * @param sort values to be added
262     * @param <TValue> value type
263     * @return ByProjectKeyBusinessUnitsGet
264     */
265    public <TValue> ByProjectKeyBusinessUnitsGet addSort(final Collection<TValue> sort) {
266        return copy().addQueryParams(
267            sort.stream().map(s -> new ParamEntry<>("sort", s.toString())).collect(Collectors.toList()));
268    }
269
270    /**
271     * set limit with the specified value
272     * @param limit value to be set
273     * @param <TValue> value type
274     * @return ByProjectKeyBusinessUnitsGet
275     */
276    public <TValue> ByProjectKeyBusinessUnitsGet withLimit(final TValue limit) {
277        return copy().withQueryParam("limit", limit);
278    }
279
280    /**
281     * add additional limit query parameter
282     * @param limit value to be added
283     * @param <TValue> value type
284     * @return ByProjectKeyBusinessUnitsGet
285     */
286    public <TValue> ByProjectKeyBusinessUnitsGet addLimit(final TValue limit) {
287        return copy().addQueryParam("limit", limit);
288    }
289
290    /**
291     * set limit with the specified value
292     * @param supplier supplier for the value to be set
293     * @return ByProjectKeyBusinessUnitsGet
294     */
295    public ByProjectKeyBusinessUnitsGet withLimit(final Supplier<Integer> supplier) {
296        return copy().withQueryParam("limit", supplier.get());
297    }
298
299    /**
300     * add additional limit query parameter
301     * @param supplier supplier for the value to be added
302     * @return ByProjectKeyBusinessUnitsGet
303     */
304    public ByProjectKeyBusinessUnitsGet addLimit(final Supplier<Integer> supplier) {
305        return copy().addQueryParam("limit", supplier.get());
306    }
307
308    /**
309     * set limit with the specified value
310     * @param op builder for the value to be set
311     * @return ByProjectKeyBusinessUnitsGet
312     */
313    public ByProjectKeyBusinessUnitsGet withLimit(final Function<StringBuilder, StringBuilder> op) {
314        return copy().withQueryParam("limit", op.apply(new StringBuilder()));
315    }
316
317    /**
318     * add additional limit query parameter
319     * @param op builder for the value to be added
320     * @return ByProjectKeyBusinessUnitsGet
321     */
322    public ByProjectKeyBusinessUnitsGet addLimit(final Function<StringBuilder, StringBuilder> op) {
323        return copy().addQueryParam("limit", op.apply(new StringBuilder()));
324    }
325
326    /**
327     * set limit with the specified values
328     * @param limit values to be set
329     * @param <TValue> value type
330     * @return ByProjectKeyBusinessUnitsGet
331     */
332    public <TValue> ByProjectKeyBusinessUnitsGet withLimit(final Collection<TValue> limit) {
333        return copy().withoutQueryParam("limit")
334                .addQueryParams(
335                    limit.stream().map(s -> new ParamEntry<>("limit", s.toString())).collect(Collectors.toList()));
336    }
337
338    /**
339     * add additional limit query parameters
340     * @param limit values to be added
341     * @param <TValue> value type
342     * @return ByProjectKeyBusinessUnitsGet
343     */
344    public <TValue> ByProjectKeyBusinessUnitsGet addLimit(final Collection<TValue> limit) {
345        return copy().addQueryParams(
346            limit.stream().map(s -> new ParamEntry<>("limit", s.toString())).collect(Collectors.toList()));
347    }
348
349    /**
350     * set offset with the specified value
351     * @param offset value to be set
352     * @param <TValue> value type
353     * @return ByProjectKeyBusinessUnitsGet
354     */
355    public <TValue> ByProjectKeyBusinessUnitsGet withOffset(final TValue offset) {
356        return copy().withQueryParam("offset", offset);
357    }
358
359    /**
360     * add additional offset query parameter
361     * @param offset value to be added
362     * @param <TValue> value type
363     * @return ByProjectKeyBusinessUnitsGet
364     */
365    public <TValue> ByProjectKeyBusinessUnitsGet addOffset(final TValue offset) {
366        return copy().addQueryParam("offset", offset);
367    }
368
369    /**
370     * set offset with the specified value
371     * @param supplier supplier for the value to be set
372     * @return ByProjectKeyBusinessUnitsGet
373     */
374    public ByProjectKeyBusinessUnitsGet withOffset(final Supplier<Integer> supplier) {
375        return copy().withQueryParam("offset", supplier.get());
376    }
377
378    /**
379     * add additional offset query parameter
380     * @param supplier supplier for the value to be added
381     * @return ByProjectKeyBusinessUnitsGet
382     */
383    public ByProjectKeyBusinessUnitsGet addOffset(final Supplier<Integer> supplier) {
384        return copy().addQueryParam("offset", supplier.get());
385    }
386
387    /**
388     * set offset with the specified value
389     * @param op builder for the value to be set
390     * @return ByProjectKeyBusinessUnitsGet
391     */
392    public ByProjectKeyBusinessUnitsGet withOffset(final Function<StringBuilder, StringBuilder> op) {
393        return copy().withQueryParam("offset", op.apply(new StringBuilder()));
394    }
395
396    /**
397     * add additional offset query parameter
398     * @param op builder for the value to be added
399     * @return ByProjectKeyBusinessUnitsGet
400     */
401    public ByProjectKeyBusinessUnitsGet addOffset(final Function<StringBuilder, StringBuilder> op) {
402        return copy().addQueryParam("offset", op.apply(new StringBuilder()));
403    }
404
405    /**
406     * set offset with the specified values
407     * @param offset values to be set
408     * @param <TValue> value type
409     * @return ByProjectKeyBusinessUnitsGet
410     */
411    public <TValue> ByProjectKeyBusinessUnitsGet withOffset(final Collection<TValue> offset) {
412        return copy().withoutQueryParam("offset")
413                .addQueryParams(
414                    offset.stream().map(s -> new ParamEntry<>("offset", s.toString())).collect(Collectors.toList()));
415    }
416
417    /**
418     * add additional offset query parameters
419     * @param offset values to be added
420     * @param <TValue> value type
421     * @return ByProjectKeyBusinessUnitsGet
422     */
423    public <TValue> ByProjectKeyBusinessUnitsGet addOffset(final Collection<TValue> offset) {
424        return copy().addQueryParams(
425            offset.stream().map(s -> new ParamEntry<>("offset", s.toString())).collect(Collectors.toList()));
426    }
427
428    /**
429     * set withTotal with the specified value
430     * @param withTotal value to be set
431     * @param <TValue> value type
432     * @return ByProjectKeyBusinessUnitsGet
433     */
434    public <TValue> ByProjectKeyBusinessUnitsGet withWithTotal(final TValue withTotal) {
435        return copy().withQueryParam("withTotal", withTotal);
436    }
437
438    /**
439     * add additional withTotal query parameter
440     * @param withTotal value to be added
441     * @param <TValue> value type
442     * @return ByProjectKeyBusinessUnitsGet
443     */
444    public <TValue> ByProjectKeyBusinessUnitsGet addWithTotal(final TValue withTotal) {
445        return copy().addQueryParam("withTotal", withTotal);
446    }
447
448    /**
449     * set withTotal with the specified value
450     * @param supplier supplier for the value to be set
451     * @return ByProjectKeyBusinessUnitsGet
452     */
453    public ByProjectKeyBusinessUnitsGet withWithTotal(final Supplier<Boolean> supplier) {
454        return copy().withQueryParam("withTotal", supplier.get());
455    }
456
457    /**
458     * add additional withTotal query parameter
459     * @param supplier supplier for the value to be added
460     * @return ByProjectKeyBusinessUnitsGet
461     */
462    public ByProjectKeyBusinessUnitsGet addWithTotal(final Supplier<Boolean> supplier) {
463        return copy().addQueryParam("withTotal", supplier.get());
464    }
465
466    /**
467     * set withTotal with the specified value
468     * @param op builder for the value to be set
469     * @return ByProjectKeyBusinessUnitsGet
470     */
471    public ByProjectKeyBusinessUnitsGet withWithTotal(final Function<StringBuilder, StringBuilder> op) {
472        return copy().withQueryParam("withTotal", op.apply(new StringBuilder()));
473    }
474
475    /**
476     * add additional withTotal query parameter
477     * @param op builder for the value to be added
478     * @return ByProjectKeyBusinessUnitsGet
479     */
480    public ByProjectKeyBusinessUnitsGet addWithTotal(final Function<StringBuilder, StringBuilder> op) {
481        return copy().addQueryParam("withTotal", op.apply(new StringBuilder()));
482    }
483
484    /**
485     * set withTotal with the specified values
486     * @param withTotal values to be set
487     * @param <TValue> value type
488     * @return ByProjectKeyBusinessUnitsGet
489     */
490    public <TValue> ByProjectKeyBusinessUnitsGet withWithTotal(final Collection<TValue> withTotal) {
491        return copy().withoutQueryParam("withTotal")
492                .addQueryParams(withTotal.stream()
493                        .map(s -> new ParamEntry<>("withTotal", s.toString()))
494                        .collect(Collectors.toList()));
495    }
496
497    /**
498     * add additional withTotal query parameters
499     * @param withTotal values to be added
500     * @param <TValue> value type
501     * @return ByProjectKeyBusinessUnitsGet
502     */
503    public <TValue> ByProjectKeyBusinessUnitsGet addWithTotal(final Collection<TValue> withTotal) {
504        return copy().addQueryParams(
505            withTotal.stream().map(s -> new ParamEntry<>("withTotal", s.toString())).collect(Collectors.toList()));
506    }
507
508    /**
509     * set where with the specified value
510     * @param where value to be set
511     * @param <TValue> value type
512     * @return ByProjectKeyBusinessUnitsGet
513     */
514    public <TValue> ByProjectKeyBusinessUnitsGet withWhere(final TValue where) {
515        return copy().withQueryParam("where", where);
516    }
517
518    /**
519     * add additional where query parameter
520     * @param where value to be added
521     * @param <TValue> value type
522     * @return ByProjectKeyBusinessUnitsGet
523     */
524    public <TValue> ByProjectKeyBusinessUnitsGet addWhere(final TValue where) {
525        return copy().addQueryParam("where", where);
526    }
527
528    /**
529     * set where with the specified value
530     * @param supplier supplier for the value to be set
531     * @return ByProjectKeyBusinessUnitsGet
532     */
533    public ByProjectKeyBusinessUnitsGet withWhere(final Supplier<String> supplier) {
534        return copy().withQueryParam("where", supplier.get());
535    }
536
537    /**
538     * add additional where query parameter
539     * @param supplier supplier for the value to be added
540     * @return ByProjectKeyBusinessUnitsGet
541     */
542    public ByProjectKeyBusinessUnitsGet addWhere(final Supplier<String> supplier) {
543        return copy().addQueryParam("where", supplier.get());
544    }
545
546    /**
547     * set where with the specified value
548     * @param op builder for the value to be set
549     * @return ByProjectKeyBusinessUnitsGet
550     */
551    public ByProjectKeyBusinessUnitsGet withWhere(final Function<StringBuilder, StringBuilder> op) {
552        return copy().withQueryParam("where", op.apply(new StringBuilder()));
553    }
554
555    /**
556     * add additional where query parameter
557     * @param op builder for the value to be added
558     * @return ByProjectKeyBusinessUnitsGet
559     */
560    public ByProjectKeyBusinessUnitsGet addWhere(final Function<StringBuilder, StringBuilder> op) {
561        return copy().addQueryParam("where", op.apply(new StringBuilder()));
562    }
563
564    /**
565     * set where with the specified values
566     * @param where values to be set
567     * @param <TValue> value type
568     * @return ByProjectKeyBusinessUnitsGet
569     */
570    public <TValue> ByProjectKeyBusinessUnitsGet withWhere(final Collection<TValue> where) {
571        return copy().withoutQueryParam("where")
572                .addQueryParams(
573                    where.stream().map(s -> new ParamEntry<>("where", s.toString())).collect(Collectors.toList()));
574    }
575
576    /**
577     * add additional where query parameters
578     * @param where values to be added
579     * @param <TValue> value type
580     * @return ByProjectKeyBusinessUnitsGet
581     */
582    public <TValue> ByProjectKeyBusinessUnitsGet addWhere(final Collection<TValue> where) {
583        return copy().addQueryParams(
584            where.stream().map(s -> new ParamEntry<>("where", s.toString())).collect(Collectors.toList()));
585    }
586
587    /**
588     * set predicateVar with the specificied value
589     * @param <TValue> value type
590     * @param varName parameter name
591     * @param predicateVar parameter value
592     * @return ByProjectKeyBusinessUnitsGet
593     */
594    public <TValue> ByProjectKeyBusinessUnitsGet withPredicateVar(final String varName, final TValue predicateVar) {
595        return copy().withQueryParam(String.format("var.%s", varName), predicateVar);
596    }
597
598    /**
599     * add additional predicateVar query parameter
600     * @param <TValue> value type
601     * @param varName parameter name
602     * @param predicateVar parameter value
603     * @return ByProjectKeyBusinessUnitsGet
604     */
605    public <TValue> ByProjectKeyBusinessUnitsGet addPredicateVar(final String varName, final TValue predicateVar) {
606        return copy().addQueryParam(String.format("var.%s", varName), predicateVar);
607    }
608
609    /**
610     * set predicateVar with the specificied values
611     * @param <TValue> value type
612     * @param varName parameter name
613     * @param predicateVar parameter values
614     * @return ByProjectKeyBusinessUnitsGet
615     */
616    public <TValue> ByProjectKeyBusinessUnitsGet withPredicateVar(final String varName,
617            final Collection<TValue> predicateVar) {
618        final String placeholderName = String.format("var.%s", varName);
619        return copy().withoutQueryParam(placeholderName)
620                .addQueryParams(predicateVar.stream()
621                        .map(s -> new ParamEntry<>(placeholderName, s.toString()))
622                        .collect(Collectors.toList()));
623    }
624
625    /**
626     * add additional predicateVar query parameters
627     * @param <TValue> value type
628     * @param varName parameter name
629     * @param predicateVar parameter values
630     * @return ByProjectKeyBusinessUnitsGet
631     */
632    public <TValue> ByProjectKeyBusinessUnitsGet addPredicateVar(final String varName,
633            final Collection<TValue> predicateVar) {
634        final String placeholderName = String.format("var.%s", varName);
635        return copy().addQueryParams(predicateVar.stream()
636                .map(s -> new ParamEntry<>(placeholderName, s.toString()))
637                .collect(Collectors.toList()));
638    }
639
640    @Override
641    public boolean equals(Object o) {
642        if (this == o)
643            return true;
644
645        if (o == null || getClass() != o.getClass())
646            return false;
647
648        ByProjectKeyBusinessUnitsGet that = (ByProjectKeyBusinessUnitsGet) o;
649
650        return new EqualsBuilder().append(projectKey, that.projectKey).isEquals();
651    }
652
653    @Override
654    public int hashCode() {
655        return new HashCodeBuilder(17, 37).append(projectKey).toHashCode();
656    }
657
658    @Override
659    protected ByProjectKeyBusinessUnitsGet copy() {
660        return new ByProjectKeyBusinessUnitsGet(this);
661    }
662}