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