001
002package com.commercetools.ml.models.common;
003
004import java.time.*;
005import java.util.*;
006import java.util.function.Function;
007
008import javax.validation.constraints.NotNull;
009
010import com.fasterxml.jackson.annotation.*;
011import com.fasterxml.jackson.databind.annotation.*;
012
013import io.vrap.rmf.base.client.utils.Generated;
014
015/**
016 * Reference
017 *
018 * <hr>
019 * Example to create a subtype instance using the builder pattern
020 * <div class=code-example>
021 * <pre><code class='java'>
022 *     Reference reference = Reference.categoryBuilder()
023 *             id("{id}")
024 *             .build()
025 * </code></pre>
026 * </div>
027 */
028@JsonSubTypes({
029        @JsonSubTypes.Type(value = com.commercetools.ml.models.common.CategoryReferenceImpl.class, name = CategoryReference.CATEGORY),
030        @JsonSubTypes.Type(value = com.commercetools.ml.models.common.ProductReferenceImpl.class, name = ProductReference.PRODUCT),
031        @JsonSubTypes.Type(value = com.commercetools.ml.models.common.ProductTypeReferenceImpl.class, name = ProductTypeReference.PRODUCT_TYPE) })
032@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "typeId", defaultImpl = ReferenceImpl.class, visible = true)
033@JsonDeserialize(as = ReferenceImpl.class)
034@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
035public interface Reference {
036
037    /**
038     *
039     */
040    @NotNull
041    @JsonProperty("typeId")
042    public ReferenceTypeId getTypeId();
043
044    /**
045     *
046     */
047    @NotNull
048    @JsonProperty("id")
049    public String getId();
050
051    public void setId(final String id);
052
053    public static com.commercetools.ml.models.common.CategoryReferenceBuilder categoryBuilder() {
054        return com.commercetools.ml.models.common.CategoryReferenceBuilder.of();
055    }
056
057    public static com.commercetools.ml.models.common.ProductReferenceBuilder productBuilder() {
058        return com.commercetools.ml.models.common.ProductReferenceBuilder.of();
059    }
060
061    public static com.commercetools.ml.models.common.ProductTypeReferenceBuilder productTypeBuilder() {
062        return com.commercetools.ml.models.common.ProductTypeReferenceBuilder.of();
063    }
064
065    default <T> T withReference(Function<Reference, T> helper) {
066        return helper.apply(this);
067    }
068
069    public static com.fasterxml.jackson.core.type.TypeReference<Reference> typeReference() {
070        return new com.fasterxml.jackson.core.type.TypeReference<Reference>() {
071            @Override
072            public String toString() {
073                return "TypeReference<Reference>";
074            }
075        };
076    }
077}