001 002package com.commercetools.history.models.change_value; 003 004import java.util.*; 005import java.util.function.Function; 006 007import io.vrap.rmf.base.client.Builder; 008import io.vrap.rmf.base.client.utils.Generated; 009 010/** 011 * ShoppingListLineItemValueBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * ShoppingListLineItemValue shoppingListLineItemValue = ShoppingListLineItemValue.builder() 017 * .id("{id}") 018 * .name(nameBuilder -> nameBuilder) 019 * .variantId(1) 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 ShoppingListLineItemValueBuilder implements Builder<ShoppingListLineItemValue> { 026 027 private String id; 028 029 private com.commercetools.history.models.common.LocalizedString name; 030 031 private Integer variantId; 032 033 /** 034 * <p><code>id</code> of the ShoppingListLineItem.</p> 035 * @param id value to be set 036 * @return Builder 037 */ 038 039 public ShoppingListLineItemValueBuilder id(final String id) { 040 this.id = id; 041 return this; 042 } 043 044 /** 045 * <p>Name of the corresponding Product the Product Variant belongs to.</p> 046 * @param builder function to build the name value 047 * @return Builder 048 */ 049 050 public ShoppingListLineItemValueBuilder name( 051 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedStringBuilder> builder) { 052 this.name = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()).build(); 053 return this; 054 } 055 056 /** 057 * <p>Name of the corresponding Product the Product Variant belongs to.</p> 058 * @param builder function to build the name value 059 * @return Builder 060 */ 061 062 public ShoppingListLineItemValueBuilder withName( 063 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedString> builder) { 064 this.name = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()); 065 return this; 066 } 067 068 /** 069 * <p>Name of the corresponding Product the Product Variant belongs to.</p> 070 * @param name value to be set 071 * @return Builder 072 */ 073 074 public ShoppingListLineItemValueBuilder name(final com.commercetools.history.models.common.LocalizedString name) { 075 this.name = name; 076 return this; 077 } 078 079 /** 080 * <p><code>id</code> of the ProductVariant the ShoppingListLineItem refers to.</p> 081 * @param variantId value to be set 082 * @return Builder 083 */ 084 085 public ShoppingListLineItemValueBuilder variantId(final Integer variantId) { 086 this.variantId = variantId; 087 return this; 088 } 089 090 /** 091 * <p><code>id</code> of the ShoppingListLineItem.</p> 092 * @return id 093 */ 094 095 public String getId() { 096 return this.id; 097 } 098 099 /** 100 * <p>Name of the corresponding Product the Product Variant belongs to.</p> 101 * @return name 102 */ 103 104 public com.commercetools.history.models.common.LocalizedString getName() { 105 return this.name; 106 } 107 108 /** 109 * <p><code>id</code> of the ProductVariant the ShoppingListLineItem refers to.</p> 110 * @return variantId 111 */ 112 113 public Integer getVariantId() { 114 return this.variantId; 115 } 116 117 /** 118 * builds ShoppingListLineItemValue with checking for non-null required values 119 * @return ShoppingListLineItemValue 120 */ 121 public ShoppingListLineItemValue build() { 122 Objects.requireNonNull(id, ShoppingListLineItemValue.class + ": id is missing"); 123 Objects.requireNonNull(name, ShoppingListLineItemValue.class + ": name is missing"); 124 Objects.requireNonNull(variantId, ShoppingListLineItemValue.class + ": variantId is missing"); 125 return new ShoppingListLineItemValueImpl(id, name, variantId); 126 } 127 128 /** 129 * builds ShoppingListLineItemValue without checking for non-null required values 130 * @return ShoppingListLineItemValue 131 */ 132 public ShoppingListLineItemValue buildUnchecked() { 133 return new ShoppingListLineItemValueImpl(id, name, variantId); 134 } 135 136 /** 137 * factory method for an instance of ShoppingListLineItemValueBuilder 138 * @return builder 139 */ 140 public static ShoppingListLineItemValueBuilder of() { 141 return new ShoppingListLineItemValueBuilder(); 142 } 143 144 /** 145 * create builder for ShoppingListLineItemValue instance 146 * @param template instance with prefilled values for the builder 147 * @return builder 148 */ 149 public static ShoppingListLineItemValueBuilder of(final ShoppingListLineItemValue template) { 150 ShoppingListLineItemValueBuilder builder = new ShoppingListLineItemValueBuilder(); 151 builder.id = template.getId(); 152 builder.name = template.getName(); 153 builder.variantId = template.getVariantId(); 154 return builder; 155 } 156 157}