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 * SetCustomerChangeBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * SetCustomerChange setCustomerChange = SetCustomerChange.builder() 017 * .change("{change}") 018 * .previousValue(previousValueBuilder -> previousValueBuilder) 019 * .nextValue(nextValueBuilder -> nextValueBuilder) 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 SetCustomerChangeBuilder implements Builder<SetCustomerChange> { 026 027 private String change; 028 029 private com.commercetools.history.models.common.Reference previousValue; 030 031 private com.commercetools.history.models.common.Reference nextValue; 032 033 /** 034 * set the value to the change 035 * @param change value to be set 036 * @return Builder 037 */ 038 039 public SetCustomerChangeBuilder change(final String change) { 040 this.change = change; 041 return this; 042 } 043 044 /** 045 * <p>Value before the change.</p> 046 * @param builder function to build the previousValue value 047 * @return Builder 048 */ 049 050 public SetCustomerChangeBuilder previousValue( 051 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.ReferenceBuilder> builder) { 052 this.previousValue = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()).build(); 053 return this; 054 } 055 056 /** 057 * <p>Value before the change.</p> 058 * @param builder function to build the previousValue value 059 * @return Builder 060 */ 061 062 public SetCustomerChangeBuilder withPreviousValue( 063 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.Reference> builder) { 064 this.previousValue = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()); 065 return this; 066 } 067 068 /** 069 * <p>Value before the change.</p> 070 * @param previousValue value to be set 071 * @return Builder 072 */ 073 074 public SetCustomerChangeBuilder previousValue( 075 final com.commercetools.history.models.common.Reference previousValue) { 076 this.previousValue = previousValue; 077 return this; 078 } 079 080 /** 081 * <p>Value after the change.</p> 082 * @param builder function to build the nextValue value 083 * @return Builder 084 */ 085 086 public SetCustomerChangeBuilder nextValue( 087 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.ReferenceBuilder> builder) { 088 this.nextValue = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()).build(); 089 return this; 090 } 091 092 /** 093 * <p>Value after the change.</p> 094 * @param builder function to build the nextValue value 095 * @return Builder 096 */ 097 098 public SetCustomerChangeBuilder withNextValue( 099 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.Reference> builder) { 100 this.nextValue = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()); 101 return this; 102 } 103 104 /** 105 * <p>Value after the change.</p> 106 * @param nextValue value to be set 107 * @return Builder 108 */ 109 110 public SetCustomerChangeBuilder nextValue(final com.commercetools.history.models.common.Reference nextValue) { 111 this.nextValue = nextValue; 112 return this; 113 } 114 115 /** 116 * value of change} 117 * @return change 118 */ 119 120 public String getChange() { 121 return this.change; 122 } 123 124 /** 125 * <p>Value before the change.</p> 126 * @return previousValue 127 */ 128 129 public com.commercetools.history.models.common.Reference getPreviousValue() { 130 return this.previousValue; 131 } 132 133 /** 134 * <p>Value after the change.</p> 135 * @return nextValue 136 */ 137 138 public com.commercetools.history.models.common.Reference getNextValue() { 139 return this.nextValue; 140 } 141 142 /** 143 * builds SetCustomerChange with checking for non-null required values 144 * @return SetCustomerChange 145 */ 146 public SetCustomerChange build() { 147 Objects.requireNonNull(change, SetCustomerChange.class + ": change is missing"); 148 Objects.requireNonNull(previousValue, SetCustomerChange.class + ": previousValue is missing"); 149 Objects.requireNonNull(nextValue, SetCustomerChange.class + ": nextValue is missing"); 150 return new SetCustomerChangeImpl(change, previousValue, nextValue); 151 } 152 153 /** 154 * builds SetCustomerChange without checking for non-null required values 155 * @return SetCustomerChange 156 */ 157 public SetCustomerChange buildUnchecked() { 158 return new SetCustomerChangeImpl(change, previousValue, nextValue); 159 } 160 161 /** 162 * factory method for an instance of SetCustomerChangeBuilder 163 * @return builder 164 */ 165 public static SetCustomerChangeBuilder of() { 166 return new SetCustomerChangeBuilder(); 167 } 168 169 /** 170 * create builder for SetCustomerChange instance 171 * @param template instance with prefilled values for the builder 172 * @return builder 173 */ 174 public static SetCustomerChangeBuilder of(final SetCustomerChange template) { 175 SetCustomerChangeBuilder builder = new SetCustomerChangeBuilder(); 176 builder.change = template.getChange(); 177 builder.previousValue = template.getPreviousValue(); 178 builder.nextValue = template.getNextValue(); 179 return builder; 180 } 181 182}