001
002package com.commercetools.history.models.common;
003
004import java.util.*;
005import java.util.function.Function;
006
007import io.vrap.rmf.base.client.Builder;
008import io.vrap.rmf.base.client.utils.Generated;
009
010/**
011 * SearchKeywordBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     SearchKeyword searchKeyword = SearchKeyword.builder()
017 *             .text("{text}")
018 *             .suggestTokenizer(suggestTokenizerBuilder -> suggestTokenizerBuilder)
019 *             .build()
020 * </code></pre>
021 * </div>
022 */
023@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
024public class SearchKeywordBuilder implements Builder<SearchKeyword> {
025
026    private String text;
027
028    private com.commercetools.history.models.common.SuggestTokenizer suggestTokenizer;
029
030    /**
031     * set the value to the text
032     * @param text value to be set
033     * @return Builder
034     */
035
036    public SearchKeywordBuilder text(final String text) {
037        this.text = text;
038        return this;
039    }
040
041    /**
042     * set the value to the suggestTokenizer using the builder function
043     * @param builder function to build the suggestTokenizer value
044     * @return Builder
045     */
046
047    public SearchKeywordBuilder suggestTokenizer(
048            Function<com.commercetools.history.models.common.SuggestTokenizerBuilder, com.commercetools.history.models.common.SuggestTokenizerBuilder> builder) {
049        this.suggestTokenizer = builder.apply(com.commercetools.history.models.common.SuggestTokenizerBuilder.of())
050                .build();
051        return this;
052    }
053
054    /**
055     * set the value to the suggestTokenizer using the builder function
056     * @param builder function to build the suggestTokenizer value
057     * @return Builder
058     */
059
060    public SearchKeywordBuilder withSuggestTokenizer(
061            Function<com.commercetools.history.models.common.SuggestTokenizerBuilder, com.commercetools.history.models.common.SuggestTokenizer> builder) {
062        this.suggestTokenizer = builder.apply(com.commercetools.history.models.common.SuggestTokenizerBuilder.of());
063        return this;
064    }
065
066    /**
067     * set the value to the suggestTokenizer
068     * @param suggestTokenizer value to be set
069     * @return Builder
070     */
071
072    public SearchKeywordBuilder suggestTokenizer(
073            final com.commercetools.history.models.common.SuggestTokenizer suggestTokenizer) {
074        this.suggestTokenizer = suggestTokenizer;
075        return this;
076    }
077
078    /**
079     * value of text}
080     * @return text
081     */
082
083    public String getText() {
084        return this.text;
085    }
086
087    /**
088     * value of suggestTokenizer}
089     * @return suggestTokenizer
090     */
091
092    public com.commercetools.history.models.common.SuggestTokenizer getSuggestTokenizer() {
093        return this.suggestTokenizer;
094    }
095
096    /**
097     * builds SearchKeyword with checking for non-null required values
098     * @return SearchKeyword
099     */
100    public SearchKeyword build() {
101        Objects.requireNonNull(text, SearchKeyword.class + ": text is missing");
102        Objects.requireNonNull(suggestTokenizer, SearchKeyword.class + ": suggestTokenizer is missing");
103        return new SearchKeywordImpl(text, suggestTokenizer);
104    }
105
106    /**
107     * builds SearchKeyword without checking for non-null required values
108     * @return SearchKeyword
109     */
110    public SearchKeyword buildUnchecked() {
111        return new SearchKeywordImpl(text, suggestTokenizer);
112    }
113
114    /**
115     * factory method for an instance of SearchKeywordBuilder
116     * @return builder
117     */
118    public static SearchKeywordBuilder of() {
119        return new SearchKeywordBuilder();
120    }
121
122    /**
123     * create builder for SearchKeyword instance
124     * @param template instance with prefilled values for the builder
125     * @return builder
126     */
127    public static SearchKeywordBuilder of(final SearchKeyword template) {
128        SearchKeywordBuilder builder = new SearchKeywordBuilder();
129        builder.text = template.getText();
130        builder.suggestTokenizer = template.getSuggestTokenizer();
131        return builder;
132    }
133
134}