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 * SetStoreChangeBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * SetStoreChange setStoreChange = SetStoreChange.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 SetStoreChangeBuilder implements Builder<SetStoreChange> { 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 SetStoreChangeBuilder 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 SetStoreChangeBuilder 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 SetStoreChangeBuilder 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 SetStoreChangeBuilder previousValue(final com.commercetools.history.models.common.Reference previousValue) { 075 this.previousValue = previousValue; 076 return this; 077 } 078 079 /** 080 * <p>Value after the change.</p> 081 * @param builder function to build the nextValue value 082 * @return Builder 083 */ 084 085 public SetStoreChangeBuilder nextValue( 086 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.ReferenceBuilder> builder) { 087 this.nextValue = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()).build(); 088 return this; 089 } 090 091 /** 092 * <p>Value after the change.</p> 093 * @param builder function to build the nextValue value 094 * @return Builder 095 */ 096 097 public SetStoreChangeBuilder withNextValue( 098 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.Reference> builder) { 099 this.nextValue = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()); 100 return this; 101 } 102 103 /** 104 * <p>Value after the change.</p> 105 * @param nextValue value to be set 106 * @return Builder 107 */ 108 109 public SetStoreChangeBuilder nextValue(final com.commercetools.history.models.common.Reference nextValue) { 110 this.nextValue = nextValue; 111 return this; 112 } 113 114 /** 115 * value of change} 116 * @return change 117 */ 118 119 public String getChange() { 120 return this.change; 121 } 122 123 /** 124 * <p>Value before the change.</p> 125 * @return previousValue 126 */ 127 128 public com.commercetools.history.models.common.Reference getPreviousValue() { 129 return this.previousValue; 130 } 131 132 /** 133 * <p>Value after the change.</p> 134 * @return nextValue 135 */ 136 137 public com.commercetools.history.models.common.Reference getNextValue() { 138 return this.nextValue; 139 } 140 141 /** 142 * builds SetStoreChange with checking for non-null required values 143 * @return SetStoreChange 144 */ 145 public SetStoreChange build() { 146 Objects.requireNonNull(change, SetStoreChange.class + ": change is missing"); 147 Objects.requireNonNull(previousValue, SetStoreChange.class + ": previousValue is missing"); 148 Objects.requireNonNull(nextValue, SetStoreChange.class + ": nextValue is missing"); 149 return new SetStoreChangeImpl(change, previousValue, nextValue); 150 } 151 152 /** 153 * builds SetStoreChange without checking for non-null required values 154 * @return SetStoreChange 155 */ 156 public SetStoreChange buildUnchecked() { 157 return new SetStoreChangeImpl(change, previousValue, nextValue); 158 } 159 160 /** 161 * factory method for an instance of SetStoreChangeBuilder 162 * @return builder 163 */ 164 public static SetStoreChangeBuilder of() { 165 return new SetStoreChangeBuilder(); 166 } 167 168 /** 169 * create builder for SetStoreChange instance 170 * @param template instance with prefilled values for the builder 171 * @return builder 172 */ 173 public static SetStoreChangeBuilder of(final SetStoreChange template) { 174 SetStoreChangeBuilder builder = new SetStoreChangeBuilder(); 175 builder.change = template.getChange(); 176 builder.previousValue = template.getPreviousValue(); 177 builder.nextValue = template.getNextValue(); 178 return builder; 179 } 180 181}