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