001
002package com.commercetools.importapi.models.customfields;
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.importapi.models.common.TypeKeyReference;
013import com.fasterxml.jackson.annotation.*;
014import com.fasterxml.jackson.databind.annotation.*;
015
016import io.vrap.rmf.base.client.utils.Generated;
017
018/**
019 *  <p>The representation to be sent to the server when creating a resource with custom fields.</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 *     Custom custom = Custom.builder()
026 *             .type(typeBuilder -> typeBuilder)
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 = CustomImpl.class)
033public interface Custom {
034
035    /**
036     *  <p>The type that provides the field definitions for this object.</p>
037     * @return type
038     */
039    @NotNull
040    @Valid
041    @JsonProperty("type")
042    public TypeKeyReference getType();
043
044    /**
045     *  <p>The custom fields of this object.</p>
046     * @return fields
047     */
048    @Valid
049    @JsonProperty("fields")
050    public FieldContainer getFields();
051
052    /**
053     *  <p>The type that provides the field definitions for this object.</p>
054     * @param type value to be set
055     */
056
057    public void setType(final TypeKeyReference type);
058
059    /**
060     *  <p>The custom fields of this object.</p>
061     * @param fields value to be set
062     */
063
064    public void setFields(final FieldContainer fields);
065
066    /**
067     * factory method
068     * @return instance of Custom
069     */
070    public static Custom of() {
071        return new CustomImpl();
072    }
073
074    /**
075     * factory method to create a shallow copy Custom
076     * @param template instance to be copied
077     * @return copy instance
078     */
079    public static Custom of(final Custom template) {
080        CustomImpl instance = new CustomImpl();
081        instance.setType(template.getType());
082        instance.setFields(template.getFields());
083        return instance;
084    }
085
086    /**
087     * factory method to create a deep copy of Custom
088     * @param template instance to be copied
089     * @return copy instance
090     */
091    @Nullable
092    public static Custom deepCopy(@Nullable final Custom template) {
093        if (template == null) {
094            return null;
095        }
096        CustomImpl instance = new CustomImpl();
097        instance.setType(com.commercetools.importapi.models.common.TypeKeyReference.deepCopy(template.getType()));
098        instance.setFields(
099            com.commercetools.importapi.models.customfields.FieldContainer.deepCopy(template.getFields()));
100        return instance;
101    }
102
103    /**
104     * builder factory method for Custom
105     * @return builder
106     */
107    public static CustomBuilder builder() {
108        return CustomBuilder.of();
109    }
110
111    /**
112     * create builder for Custom instance
113     * @param template instance with prefilled values for the builder
114     * @return builder
115     */
116    public static CustomBuilder builder(final Custom template) {
117        return CustomBuilder.of(template);
118    }
119
120    /**
121     * accessor map function
122     * @param <T> mapped type
123     * @param helper function to map the object
124     * @return mapped value
125     */
126    default <T> T withCustom(Function<Custom, T> helper) {
127        return helper.apply(this);
128    }
129
130    /**
131     * gives a TypeReference for usage with Jackson DataBind
132     * @return TypeReference
133     */
134    public static com.fasterxml.jackson.core.type.TypeReference<Custom> typeReference() {
135        return new com.fasterxml.jackson.core.type.TypeReference<Custom>() {
136            @Override
137            public String toString() {
138                return "TypeReference<Custom>";
139            }
140        };
141    }
142}