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