001 002package com.commercetools.api.models.error; 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 * DuplicatePriceScopeErrorBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * DuplicatePriceScopeError duplicatePriceScopeError = DuplicatePriceScopeError.builder() 017 * .message("{message}") 018 * .conflictingPrice(conflictingPriceBuilder -> conflictingPriceBuilder) 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 DuplicatePriceScopeErrorBuilder implements Builder<DuplicatePriceScopeError> { 025 026 private String message; 027 028 private Map<String, java.lang.Object> values = new HashMap<>(); 029 030 private com.commercetools.api.models.common.Price conflictingPrice; 031 032 /** 033 * <p><code>"Duplicate price scope: $priceScope. The combination of currency, country, customerGroup and channel must be unique for each price of a product variant."</code></p> 034 * @param message value to be set 035 * @return Builder 036 */ 037 038 public DuplicatePriceScopeErrorBuilder message(final String message) { 039 this.message = message; 040 return this; 041 } 042 043 /** 044 * <p>Error-specific additional fields.</p> 045 * @param values properties to be set 046 * @return Builder 047 */ 048 049 public DuplicatePriceScopeErrorBuilder values(final Map<String, java.lang.Object> values) { 050 this.values = values; 051 return this; 052 } 053 054 /** 055 * <p>Error-specific additional fields.</p> 056 * @param key property name 057 * @param value property value 058 * @return Builder 059 */ 060 061 public DuplicatePriceScopeErrorBuilder addValue(final String key, final java.lang.Object value) { 062 if (this.values == null) { 063 values = new HashMap<>(); 064 } 065 values.put(key, value); 066 return this; 067 } 068 069 /** 070 * <p>Conflicting Embedded Price.</p> 071 * @param builder function to build the conflictingPrice value 072 * @return Builder 073 */ 074 075 public DuplicatePriceScopeErrorBuilder conflictingPrice( 076 Function<com.commercetools.api.models.common.PriceBuilder, com.commercetools.api.models.common.PriceBuilder> builder) { 077 this.conflictingPrice = builder.apply(com.commercetools.api.models.common.PriceBuilder.of()).build(); 078 return this; 079 } 080 081 /** 082 * <p>Conflicting Embedded Price.</p> 083 * @param builder function to build the conflictingPrice value 084 * @return Builder 085 */ 086 087 public DuplicatePriceScopeErrorBuilder withConflictingPrice( 088 Function<com.commercetools.api.models.common.PriceBuilder, com.commercetools.api.models.common.Price> builder) { 089 this.conflictingPrice = builder.apply(com.commercetools.api.models.common.PriceBuilder.of()); 090 return this; 091 } 092 093 /** 094 * <p>Conflicting Embedded Price.</p> 095 * @param conflictingPrice value to be set 096 * @return Builder 097 */ 098 099 public DuplicatePriceScopeErrorBuilder conflictingPrice( 100 final com.commercetools.api.models.common.Price conflictingPrice) { 101 this.conflictingPrice = conflictingPrice; 102 return this; 103 } 104 105 /** 106 * <p><code>"Duplicate price scope: $priceScope. The combination of currency, country, customerGroup and channel must be unique for each price of a product variant."</code></p> 107 * @return message 108 */ 109 110 public String getMessage() { 111 return this.message; 112 } 113 114 /** 115 * <p>Error-specific additional fields.</p> 116 * @return pattern properties 117 */ 118 119 public Map<String, java.lang.Object> getValues() { 120 return this.values; 121 } 122 123 /** 124 * <p>Conflicting Embedded Price.</p> 125 * @return conflictingPrice 126 */ 127 128 public com.commercetools.api.models.common.Price getConflictingPrice() { 129 return this.conflictingPrice; 130 } 131 132 /** 133 * builds DuplicatePriceScopeError with checking for non-null required values 134 * @return DuplicatePriceScopeError 135 */ 136 public DuplicatePriceScopeError build() { 137 Objects.requireNonNull(message, DuplicatePriceScopeError.class + ": message is missing"); 138 Objects.requireNonNull(conflictingPrice, DuplicatePriceScopeError.class + ": conflictingPrice is missing"); 139 return new DuplicatePriceScopeErrorImpl(message, values, conflictingPrice); 140 } 141 142 /** 143 * builds DuplicatePriceScopeError without checking for non-null required values 144 * @return DuplicatePriceScopeError 145 */ 146 public DuplicatePriceScopeError buildUnchecked() { 147 return new DuplicatePriceScopeErrorImpl(message, values, conflictingPrice); 148 } 149 150 /** 151 * factory method for an instance of DuplicatePriceScopeErrorBuilder 152 * @return builder 153 */ 154 public static DuplicatePriceScopeErrorBuilder of() { 155 return new DuplicatePriceScopeErrorBuilder(); 156 } 157 158 /** 159 * create builder for DuplicatePriceScopeError instance 160 * @param template instance with prefilled values for the builder 161 * @return builder 162 */ 163 public static DuplicatePriceScopeErrorBuilder of(final DuplicatePriceScopeError template) { 164 DuplicatePriceScopeErrorBuilder builder = new DuplicatePriceScopeErrorBuilder(); 165 builder.message = template.getMessage(); 166 builder.values = template.values(); 167 builder.conflictingPrice = template.getConflictingPrice(); 168 return builder; 169 } 170 171}