001 002package com.commercetools.api.models.error; 003 004import java.util.*; 005 006import io.vrap.rmf.base.client.Builder; 007import io.vrap.rmf.base.client.utils.Generated; 008 009/** 010 * PriceChangedErrorBuilder 011 * <hr> 012 * Example to create an instance using the builder pattern 013 * <div class=code-example> 014 * <pre><code class='java'> 015 * PriceChangedError priceChangedError = PriceChangedError.builder() 016 * .message("{message}") 017 * .plusLineItems(lineItemsBuilder -> lineItemsBuilder) 018 * .shipping(true) 019 * .build() 020 * </code></pre> 021 * </div> 022 */ 023@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 024public class PriceChangedErrorBuilder implements Builder<PriceChangedError> { 025 026 private String message; 027 028 private Map<String, java.lang.Object> values = new HashMap<>(); 029 030 private java.util.List<String> lineItems; 031 032 private Boolean shipping; 033 034 /** 035 * <p>Plain text description of the reason for the Price change. For example, <code>"The price or tax of some line items changed at the time of placing the order: $lineItems."</code>.</p> 036 * @param message value to be set 037 * @return Builder 038 */ 039 040 public PriceChangedErrorBuilder message(final String message) { 041 this.message = message; 042 return this; 043 } 044 045 /** 046 * <p>Error-specific additional fields.</p> 047 * @param values properties to be set 048 * @return Builder 049 */ 050 051 public PriceChangedErrorBuilder values(final Map<String, java.lang.Object> values) { 052 this.values = values; 053 return this; 054 } 055 056 /** 057 * <p>Error-specific additional fields.</p> 058 * @param key property name 059 * @param value property value 060 * @return Builder 061 */ 062 063 public PriceChangedErrorBuilder addValue(final String key, final java.lang.Object value) { 064 if (this.values == null) { 065 values = new HashMap<>(); 066 } 067 values.put(key, value); 068 return this; 069 } 070 071 /** 072 * <p>Unique identifiers of the Line Items for which the Price or TaxRate has changed.</p> 073 * @param lineItems value to be set 074 * @return Builder 075 */ 076 077 public PriceChangedErrorBuilder lineItems(final String... lineItems) { 078 this.lineItems = new ArrayList<>(Arrays.asList(lineItems)); 079 return this; 080 } 081 082 /** 083 * <p>Unique identifiers of the Line Items for which the Price or TaxRate has changed.</p> 084 * @param lineItems value to be set 085 * @return Builder 086 */ 087 088 public PriceChangedErrorBuilder lineItems(final java.util.List<String> lineItems) { 089 this.lineItems = lineItems; 090 return this; 091 } 092 093 /** 094 * <p>Unique identifiers of the Line Items for which the Price or TaxRate has changed.</p> 095 * @param lineItems value to be set 096 * @return Builder 097 */ 098 099 public PriceChangedErrorBuilder plusLineItems(final String... lineItems) { 100 if (this.lineItems == null) { 101 this.lineItems = new ArrayList<>(); 102 } 103 this.lineItems.addAll(Arrays.asList(lineItems)); 104 return this; 105 } 106 107 /** 108 * <p><code>true</code> if the ShippingRate has changed.</p> 109 * @param shipping value to be set 110 * @return Builder 111 */ 112 113 public PriceChangedErrorBuilder shipping(final Boolean shipping) { 114 this.shipping = shipping; 115 return this; 116 } 117 118 /** 119 * <p>Plain text description of the reason for the Price change. For example, <code>"The price or tax of some line items changed at the time of placing the order: $lineItems."</code>.</p> 120 * @return message 121 */ 122 123 public String getMessage() { 124 return this.message; 125 } 126 127 /** 128 * <p>Error-specific additional fields.</p> 129 * @return pattern properties 130 */ 131 132 public Map<String, java.lang.Object> getValues() { 133 return this.values; 134 } 135 136 /** 137 * <p>Unique identifiers of the Line Items for which the Price or TaxRate has changed.</p> 138 * @return lineItems 139 */ 140 141 public java.util.List<String> getLineItems() { 142 return this.lineItems; 143 } 144 145 /** 146 * <p><code>true</code> if the ShippingRate has changed.</p> 147 * @return shipping 148 */ 149 150 public Boolean getShipping() { 151 return this.shipping; 152 } 153 154 /** 155 * builds PriceChangedError with checking for non-null required values 156 * @return PriceChangedError 157 */ 158 public PriceChangedError build() { 159 Objects.requireNonNull(message, PriceChangedError.class + ": message is missing"); 160 Objects.requireNonNull(lineItems, PriceChangedError.class + ": lineItems is missing"); 161 Objects.requireNonNull(shipping, PriceChangedError.class + ": shipping is missing"); 162 return new PriceChangedErrorImpl(message, values, lineItems, shipping); 163 } 164 165 /** 166 * builds PriceChangedError without checking for non-null required values 167 * @return PriceChangedError 168 */ 169 public PriceChangedError buildUnchecked() { 170 return new PriceChangedErrorImpl(message, values, lineItems, shipping); 171 } 172 173 /** 174 * factory method for an instance of PriceChangedErrorBuilder 175 * @return builder 176 */ 177 public static PriceChangedErrorBuilder of() { 178 return new PriceChangedErrorBuilder(); 179 } 180 181 /** 182 * create builder for PriceChangedError instance 183 * @param template instance with prefilled values for the builder 184 * @return builder 185 */ 186 public static PriceChangedErrorBuilder of(final PriceChangedError template) { 187 PriceChangedErrorBuilder builder = new PriceChangedErrorBuilder(); 188 builder.message = template.getMessage(); 189 builder.values = template.values(); 190 builder.lineItems = template.getLineItems(); 191 builder.shipping = template.getShipping(); 192 return builder; 193 } 194 195}