001 002package com.commercetools.api.models.cart; 003 004import java.util.*; 005import java.util.function.Function; 006 007import javax.annotation.Nullable; 008 009import io.vrap.rmf.base.client.Builder; 010import io.vrap.rmf.base.client.utils.Generated; 011 012/** 013 * ReplicaCartDraftBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * ReplicaCartDraft replicaCartDraft = ReplicaCartDraft.builder() 019 * .reference(referenceBuilder -> referenceBuilder) 020 * .build() 021 * </code></pre> 022 * </div> 023 */ 024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 025public class ReplicaCartDraftBuilder implements Builder<ReplicaCartDraft> { 026 027 private com.commercetools.api.models.common.Reference reference; 028 029 @Nullable 030 private String key; 031 032 /** 033 * <p>A Reference represents a loose reference to another resource in the same Project identified by its <code>id</code>. The <code>typeId</code> indicates the type of the referenced resource. Each resource type has its corresponding Reference type, like ChannelReference. A referenced resource can be embedded through Reference Expansion. The expanded reference is the value of an additional <code>obj</code> field then.</p> 034 * @param reference value to be set 035 * @return Builder 036 */ 037 038 public ReplicaCartDraftBuilder reference(final com.commercetools.api.models.common.Reference reference) { 039 this.reference = reference; 040 return this; 041 } 042 043 /** 044 * <p>A Reference represents a loose reference to another resource in the same Project identified by its <code>id</code>. The <code>typeId</code> indicates the type of the referenced resource. Each resource type has its corresponding Reference type, like ChannelReference. A referenced resource can be embedded through Reference Expansion. The expanded reference is the value of an additional <code>obj</code> field then.</p> 045 * @param builder function to build the reference value 046 * @return Builder 047 */ 048 049 public ReplicaCartDraftBuilder reference( 050 Function<com.commercetools.api.models.common.ReferenceBuilder, Builder<? extends com.commercetools.api.models.common.Reference>> builder) { 051 this.reference = builder.apply(com.commercetools.api.models.common.ReferenceBuilder.of()).build(); 052 return this; 053 } 054 055 /** 056 * <p>User-defined unique identifier for the Cart.</p> 057 * @param key value to be set 058 * @return Builder 059 */ 060 061 public ReplicaCartDraftBuilder key(@Nullable final String key) { 062 this.key = key; 063 return this; 064 } 065 066 /** 067 * <p>A Reference represents a loose reference to another resource in the same Project identified by its <code>id</code>. The <code>typeId</code> indicates the type of the referenced resource. Each resource type has its corresponding Reference type, like ChannelReference. A referenced resource can be embedded through Reference Expansion. The expanded reference is the value of an additional <code>obj</code> field then.</p> 068 * @return reference 069 */ 070 071 public com.commercetools.api.models.common.Reference getReference() { 072 return this.reference; 073 } 074 075 /** 076 * <p>User-defined unique identifier for the Cart.</p> 077 * @return key 078 */ 079 080 @Nullable 081 public String getKey() { 082 return this.key; 083 } 084 085 /** 086 * builds ReplicaCartDraft with checking for non-null required values 087 * @return ReplicaCartDraft 088 */ 089 public ReplicaCartDraft build() { 090 Objects.requireNonNull(reference, ReplicaCartDraft.class + ": reference is missing"); 091 return new ReplicaCartDraftImpl(reference, key); 092 } 093 094 /** 095 * builds ReplicaCartDraft without checking for non-null required values 096 * @return ReplicaCartDraft 097 */ 098 public ReplicaCartDraft buildUnchecked() { 099 return new ReplicaCartDraftImpl(reference, key); 100 } 101 102 /** 103 * factory method for an instance of ReplicaCartDraftBuilder 104 * @return builder 105 */ 106 public static ReplicaCartDraftBuilder of() { 107 return new ReplicaCartDraftBuilder(); 108 } 109 110 /** 111 * create builder for ReplicaCartDraft instance 112 * @param template instance with prefilled values for the builder 113 * @return builder 114 */ 115 public static ReplicaCartDraftBuilder of(final ReplicaCartDraft template) { 116 ReplicaCartDraftBuilder builder = new ReplicaCartDraftBuilder(); 117 builder.reference = template.getReference(); 118 builder.key = template.getKey(); 119 return builder; 120 } 121 122}