001
002package com.commercetools.api.models.discount_code;
003
004import java.time.*;
005import java.util.*;
006import java.util.function.Function;
007
008import javax.annotation.Nullable;
009import javax.validation.Valid;
010import javax.validation.constraints.NotNull;
011
012import com.commercetools.api.models.common.Reference;
013import com.fasterxml.jackson.annotation.*;
014import com.fasterxml.jackson.databind.annotation.*;
015
016import io.vrap.rmf.base.client.utils.Generated;
017
018/**
019 *  <p>Reference to a DiscountCode.</p>
020 *
021 * <hr>
022 * Example to create an instance using the builder pattern
023 * <div class=code-example>
024 * <pre><code class='java'>
025 *     DiscountCodeReference discountCodeReference = DiscountCodeReference.builder()
026 *             .id("{id}")
027 *             .build()
028 * </code></pre>
029 * </div>
030 */
031@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
032@JsonDeserialize(as = DiscountCodeReferenceImpl.class)
033public interface DiscountCodeReference extends Reference, com.commercetools.api.models.Identifiable<DiscountCode> {
034
035    /**
036     * discriminator value for DiscountCodeReference
037     */
038    String DISCOUNT_CODE = "discount-code";
039
040    /**
041     *  <p>Contains the representation of the expanded DiscountCode. Only present in responses to requests with Reference Expansion for DiscountCodes.</p>
042     * @return obj
043     */
044    @Valid
045    @JsonProperty("obj")
046    public DiscountCode getObj();
047
048    /**
049     *  <p>Unique identifier of the referenced DiscountCode.</p>
050     * @return id
051     */
052    @NotNull
053    @JsonProperty("id")
054    public String getId();
055
056    /**
057     *  <p>Contains the representation of the expanded DiscountCode. Only present in responses to requests with Reference Expansion for DiscountCodes.</p>
058     * @param obj value to be set
059     */
060
061    public void setObj(final DiscountCode obj);
062
063    /**
064     *  <p>Unique identifier of the referenced DiscountCode.</p>
065     * @param id value to be set
066     */
067
068    public void setId(final String id);
069
070    /**
071     * factory method
072     * @return instance of DiscountCodeReference
073     */
074    public static DiscountCodeReference of() {
075        return new DiscountCodeReferenceImpl();
076    }
077
078    /**
079     * factory method to create a shallow copy DiscountCodeReference
080     * @param template instance to be copied
081     * @return copy instance
082     */
083    public static DiscountCodeReference of(final DiscountCodeReference template) {
084        DiscountCodeReferenceImpl instance = new DiscountCodeReferenceImpl();
085        instance.setId(template.getId());
086        instance.setObj(template.getObj());
087        return instance;
088    }
089
090    /**
091     * factory method to create a deep copy of DiscountCodeReference
092     * @param template instance to be copied
093     * @return copy instance
094     */
095    @Nullable
096    public static DiscountCodeReference deepCopy(@Nullable final DiscountCodeReference template) {
097        if (template == null) {
098            return null;
099        }
100        DiscountCodeReferenceImpl instance = new DiscountCodeReferenceImpl();
101        instance.setId(template.getId());
102        instance.setObj(com.commercetools.api.models.discount_code.DiscountCode.deepCopy(template.getObj()));
103        return instance;
104    }
105
106    /**
107     * builder factory method for DiscountCodeReference
108     * @return builder
109     */
110    public static DiscountCodeReferenceBuilder builder() {
111        return DiscountCodeReferenceBuilder.of();
112    }
113
114    /**
115     * create builder for DiscountCodeReference instance
116     * @param template instance with prefilled values for the builder
117     * @return builder
118     */
119    public static DiscountCodeReferenceBuilder builder(final DiscountCodeReference template) {
120        return DiscountCodeReferenceBuilder.of(template);
121    }
122
123    /**
124     * accessor map function
125     * @param <T> mapped type
126     * @param helper function to map the object
127     * @return mapped value
128     */
129    default <T> T withDiscountCodeReference(Function<DiscountCodeReference, T> helper) {
130        return helper.apply(this);
131    }
132
133    /**
134     * gives a TypeReference for usage with Jackson DataBind
135     * @return TypeReference
136     */
137    public static com.fasterxml.jackson.core.type.TypeReference<DiscountCodeReference> typeReference() {
138        return new com.fasterxml.jackson.core.type.TypeReference<DiscountCodeReference>() {
139            @Override
140            public String toString() {
141                return "TypeReference<DiscountCodeReference>";
142            }
143        };
144    }
145}