001 002package com.commercetools.history.models.change; 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 * SetLineItemProductKeyChangeBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * SetLineItemProductKeyChange setLineItemProductKeyChange = SetLineItemProductKeyChange.builder() 017 * .change("{change}") 018 * .previousValue("{previousValue}") 019 * .nextValue("{nextValue}") 020 * .lineItem(lineItemBuilder -> lineItemBuilder) 021 * .lineItemId("{lineItemId}") 022 * .variant("{variant}") 023 * .build() 024 * </code></pre> 025 * </div> 026 */ 027@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 028public class SetLineItemProductKeyChangeBuilder implements Builder<SetLineItemProductKeyChange> { 029 030 private String change; 031 032 private String previousValue; 033 034 private String nextValue; 035 036 private com.commercetools.history.models.common.LocalizedString lineItem; 037 038 private String lineItemId; 039 040 private String variant; 041 042 /** 043 * set the value to the change 044 * @param change value to be set 045 * @return Builder 046 */ 047 048 public SetLineItemProductKeyChangeBuilder change(final String change) { 049 this.change = change; 050 return this; 051 } 052 053 /** 054 * <p>Value before the change.</p> 055 * @param previousValue value to be set 056 * @return Builder 057 */ 058 059 public SetLineItemProductKeyChangeBuilder previousValue(final String previousValue) { 060 this.previousValue = previousValue; 061 return this; 062 } 063 064 /** 065 * <p>Value after the change.</p> 066 * @param nextValue value to be set 067 * @return Builder 068 */ 069 070 public SetLineItemProductKeyChangeBuilder nextValue(final String nextValue) { 071 this.nextValue = nextValue; 072 return this; 073 } 074 075 /** 076 * <p>Name of the Product the Line Item is based on.</p> 077 * @param builder function to build the lineItem value 078 * @return Builder 079 */ 080 081 public SetLineItemProductKeyChangeBuilder lineItem( 082 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedStringBuilder> builder) { 083 this.lineItem = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()).build(); 084 return this; 085 } 086 087 /** 088 * <p>Name of the Product the Line Item is based on.</p> 089 * @param builder function to build the lineItem value 090 * @return Builder 091 */ 092 093 public SetLineItemProductKeyChangeBuilder withLineItem( 094 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedString> builder) { 095 this.lineItem = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()); 096 return this; 097 } 098 099 /** 100 * <p>Name of the Product the Line Item is based on.</p> 101 * @param lineItem value to be set 102 * @return Builder 103 */ 104 105 public SetLineItemProductKeyChangeBuilder lineItem( 106 final com.commercetools.history.models.common.LocalizedString lineItem) { 107 this.lineItem = lineItem; 108 return this; 109 } 110 111 /** 112 * <p><code>id</code> of the updated LineItem.</p> 113 * @param lineItemId value to be set 114 * @return Builder 115 */ 116 117 public SetLineItemProductKeyChangeBuilder lineItemId(final String lineItemId) { 118 this.lineItemId = lineItemId; 119 return this; 120 } 121 122 /** 123 * <p><code>sku</code> or <code>key</code> of the updated ProductVariant.</p> 124 * @param variant value to be set 125 * @return Builder 126 */ 127 128 public SetLineItemProductKeyChangeBuilder variant(final String variant) { 129 this.variant = variant; 130 return this; 131 } 132 133 /** 134 * value of change} 135 * @return change 136 */ 137 138 public String getChange() { 139 return this.change; 140 } 141 142 /** 143 * <p>Value before the change.</p> 144 * @return previousValue 145 */ 146 147 public String getPreviousValue() { 148 return this.previousValue; 149 } 150 151 /** 152 * <p>Value after the change.</p> 153 * @return nextValue 154 */ 155 156 public String getNextValue() { 157 return this.nextValue; 158 } 159 160 /** 161 * <p>Name of the Product the Line Item is based on.</p> 162 * @return lineItem 163 */ 164 165 public com.commercetools.history.models.common.LocalizedString getLineItem() { 166 return this.lineItem; 167 } 168 169 /** 170 * <p><code>id</code> of the updated LineItem.</p> 171 * @return lineItemId 172 */ 173 174 public String getLineItemId() { 175 return this.lineItemId; 176 } 177 178 /** 179 * <p><code>sku</code> or <code>key</code> of the updated ProductVariant.</p> 180 * @return variant 181 */ 182 183 public String getVariant() { 184 return this.variant; 185 } 186 187 /** 188 * builds SetLineItemProductKeyChange with checking for non-null required values 189 * @return SetLineItemProductKeyChange 190 */ 191 public SetLineItemProductKeyChange build() { 192 Objects.requireNonNull(change, SetLineItemProductKeyChange.class + ": change is missing"); 193 Objects.requireNonNull(previousValue, SetLineItemProductKeyChange.class + ": previousValue is missing"); 194 Objects.requireNonNull(nextValue, SetLineItemProductKeyChange.class + ": nextValue is missing"); 195 Objects.requireNonNull(lineItem, SetLineItemProductKeyChange.class + ": lineItem is missing"); 196 Objects.requireNonNull(lineItemId, SetLineItemProductKeyChange.class + ": lineItemId is missing"); 197 Objects.requireNonNull(variant, SetLineItemProductKeyChange.class + ": variant is missing"); 198 return new SetLineItemProductKeyChangeImpl(change, previousValue, nextValue, lineItem, lineItemId, variant); 199 } 200 201 /** 202 * builds SetLineItemProductKeyChange without checking for non-null required values 203 * @return SetLineItemProductKeyChange 204 */ 205 public SetLineItemProductKeyChange buildUnchecked() { 206 return new SetLineItemProductKeyChangeImpl(change, previousValue, nextValue, lineItem, lineItemId, variant); 207 } 208 209 /** 210 * factory method for an instance of SetLineItemProductKeyChangeBuilder 211 * @return builder 212 */ 213 public static SetLineItemProductKeyChangeBuilder of() { 214 return new SetLineItemProductKeyChangeBuilder(); 215 } 216 217 /** 218 * create builder for SetLineItemProductKeyChange instance 219 * @param template instance with prefilled values for the builder 220 * @return builder 221 */ 222 public static SetLineItemProductKeyChangeBuilder of(final SetLineItemProductKeyChange template) { 223 SetLineItemProductKeyChangeBuilder builder = new SetLineItemProductKeyChangeBuilder(); 224 builder.change = template.getChange(); 225 builder.previousValue = template.getPreviousValue(); 226 builder.nextValue = template.getNextValue(); 227 builder.lineItem = template.getLineItem(); 228 builder.lineItemId = template.getLineItemId(); 229 builder.variant = template.getVariant(); 230 return builder; 231 } 232 233}