001
002package com.commercetools.history.models.common;
003
004import java.util.*;
005
006import io.vrap.rmf.base.client.Builder;
007import io.vrap.rmf.base.client.utils.Generated;
008
009/**
010 * LocationBuilder
011 * <hr>
012 * Example to create an instance using the builder pattern
013 * <div class=code-example>
014 * <pre><code class='java'>
015 *     Location location = Location.builder()
016 *             .country("{country}")
017 *             .state("{state}")
018 *             .build()
019 * </code></pre>
020 * </div>
021 */
022@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
023public class LocationBuilder implements Builder<Location> {
024
025    private String country;
026
027    private String state;
028
029    /**
030     *  <p>Two-digit country code as per ISO 3166-1 alpha-2.</p>
031     * @param country value to be set
032     * @return Builder
033     */
034
035    public LocationBuilder country(final String country) {
036        this.country = country;
037        return this;
038    }
039
040    /**
041     * set the value to the state
042     * @param state value to be set
043     * @return Builder
044     */
045
046    public LocationBuilder state(final String state) {
047        this.state = state;
048        return this;
049    }
050
051    /**
052     *  <p>Two-digit country code as per ISO 3166-1 alpha-2.</p>
053     * @return country
054     */
055
056    public String getCountry() {
057        return this.country;
058    }
059
060    /**
061     * value of state}
062     * @return state
063     */
064
065    public String getState() {
066        return this.state;
067    }
068
069    /**
070     * builds Location with checking for non-null required values
071     * @return Location
072     */
073    public Location build() {
074        Objects.requireNonNull(country, Location.class + ": country is missing");
075        Objects.requireNonNull(state, Location.class + ": state is missing");
076        return new LocationImpl(country, state);
077    }
078
079    /**
080     * builds Location without checking for non-null required values
081     * @return Location
082     */
083    public Location buildUnchecked() {
084        return new LocationImpl(country, state);
085    }
086
087    /**
088     * factory method for an instance of LocationBuilder
089     * @return builder
090     */
091    public static LocationBuilder of() {
092        return new LocationBuilder();
093    }
094
095    /**
096     * create builder for Location instance
097     * @param template instance with prefilled values for the builder
098     * @return builder
099     */
100    public static LocationBuilder of(final Location template) {
101        LocationBuilder builder = new LocationBuilder();
102        builder.country = template.getCountry();
103        builder.state = template.getState();
104        return builder;
105    }
106
107}