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 * GraphQLStoreCartDiscountsLimitReachedErrorBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * GraphQLStoreCartDiscountsLimitReachedError graphQLStoreCartDiscountsLimitReachedError = GraphQLStoreCartDiscountsLimitReachedError.builder() 017 * .plusStores(storesBuilder -> storesBuilder) 018 * .build() 019 * </code></pre> 020 * </div> 021 */ 022@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 023public class GraphQLStoreCartDiscountsLimitReachedErrorBuilder 024 implements Builder<GraphQLStoreCartDiscountsLimitReachedError> { 025 026 private Map<String, java.lang.Object> values = new HashMap<>(); 027 028 private java.util.List<com.commercetools.api.models.store.StoreKeyReference> stores; 029 030 /** 031 * <p>Error-specific additional fields.</p> 032 * @param values properties to be set 033 * @return Builder 034 */ 035 036 public GraphQLStoreCartDiscountsLimitReachedErrorBuilder values(final Map<String, java.lang.Object> values) { 037 this.values = values; 038 return this; 039 } 040 041 /** 042 * <p>Error-specific additional fields.</p> 043 * @param key property name 044 * @param value property value 045 * @return Builder 046 */ 047 048 public GraphQLStoreCartDiscountsLimitReachedErrorBuilder addValue(final String key, final java.lang.Object value) { 049 if (this.values == null) { 050 values = new HashMap<>(); 051 } 052 values.put(key, value); 053 return this; 054 } 055 056 /** 057 * <p>Stores for which the limit for active Cart Discounts that can exist has been reached.</p> 058 * @param stores value to be set 059 * @return Builder 060 */ 061 062 public GraphQLStoreCartDiscountsLimitReachedErrorBuilder stores( 063 final com.commercetools.api.models.store.StoreKeyReference... stores) { 064 this.stores = new ArrayList<>(Arrays.asList(stores)); 065 return this; 066 } 067 068 /** 069 * <p>Stores for which the limit for active Cart Discounts that can exist has been reached.</p> 070 * @param stores value to be set 071 * @return Builder 072 */ 073 074 public GraphQLStoreCartDiscountsLimitReachedErrorBuilder stores( 075 final java.util.List<com.commercetools.api.models.store.StoreKeyReference> stores) { 076 this.stores = stores; 077 return this; 078 } 079 080 /** 081 * <p>Stores for which the limit for active Cart Discounts that can exist has been reached.</p> 082 * @param stores value to be set 083 * @return Builder 084 */ 085 086 public GraphQLStoreCartDiscountsLimitReachedErrorBuilder plusStores( 087 final com.commercetools.api.models.store.StoreKeyReference... stores) { 088 if (this.stores == null) { 089 this.stores = new ArrayList<>(); 090 } 091 this.stores.addAll(Arrays.asList(stores)); 092 return this; 093 } 094 095 /** 096 * <p>Stores for which the limit for active Cart Discounts that can exist has been reached.</p> 097 * @param builder function to build the stores value 098 * @return Builder 099 */ 100 101 public GraphQLStoreCartDiscountsLimitReachedErrorBuilder plusStores( 102 Function<com.commercetools.api.models.store.StoreKeyReferenceBuilder, com.commercetools.api.models.store.StoreKeyReferenceBuilder> builder) { 103 if (this.stores == null) { 104 this.stores = new ArrayList<>(); 105 } 106 this.stores.add(builder.apply(com.commercetools.api.models.store.StoreKeyReferenceBuilder.of()).build()); 107 return this; 108 } 109 110 /** 111 * <p>Stores for which the limit for active Cart Discounts that can exist has been reached.</p> 112 * @param builder function to build the stores value 113 * @return Builder 114 */ 115 116 public GraphQLStoreCartDiscountsLimitReachedErrorBuilder withStores( 117 Function<com.commercetools.api.models.store.StoreKeyReferenceBuilder, com.commercetools.api.models.store.StoreKeyReferenceBuilder> builder) { 118 this.stores = new ArrayList<>(); 119 this.stores.add(builder.apply(com.commercetools.api.models.store.StoreKeyReferenceBuilder.of()).build()); 120 return this; 121 } 122 123 /** 124 * <p>Stores for which the limit for active Cart Discounts that can exist has been reached.</p> 125 * @param builder function to build the stores value 126 * @return Builder 127 */ 128 129 public GraphQLStoreCartDiscountsLimitReachedErrorBuilder addStores( 130 Function<com.commercetools.api.models.store.StoreKeyReferenceBuilder, com.commercetools.api.models.store.StoreKeyReference> builder) { 131 return plusStores(builder.apply(com.commercetools.api.models.store.StoreKeyReferenceBuilder.of())); 132 } 133 134 /** 135 * <p>Stores for which the limit for active Cart Discounts that can exist has been reached.</p> 136 * @param builder function to build the stores value 137 * @return Builder 138 */ 139 140 public GraphQLStoreCartDiscountsLimitReachedErrorBuilder setStores( 141 Function<com.commercetools.api.models.store.StoreKeyReferenceBuilder, com.commercetools.api.models.store.StoreKeyReference> builder) { 142 return stores(builder.apply(com.commercetools.api.models.store.StoreKeyReferenceBuilder.of())); 143 } 144 145 /** 146 * <p>Error-specific additional fields.</p> 147 * @return pattern properties 148 */ 149 150 public Map<String, java.lang.Object> getValues() { 151 return this.values; 152 } 153 154 /** 155 * <p>Stores for which the limit for active Cart Discounts that can exist has been reached.</p> 156 * @return stores 157 */ 158 159 public java.util.List<com.commercetools.api.models.store.StoreKeyReference> getStores() { 160 return this.stores; 161 } 162 163 /** 164 * builds GraphQLStoreCartDiscountsLimitReachedError with checking for non-null required values 165 * @return GraphQLStoreCartDiscountsLimitReachedError 166 */ 167 public GraphQLStoreCartDiscountsLimitReachedError build() { 168 Objects.requireNonNull(stores, GraphQLStoreCartDiscountsLimitReachedError.class + ": stores is missing"); 169 return new GraphQLStoreCartDiscountsLimitReachedErrorImpl(values, stores); 170 } 171 172 /** 173 * builds GraphQLStoreCartDiscountsLimitReachedError without checking for non-null required values 174 * @return GraphQLStoreCartDiscountsLimitReachedError 175 */ 176 public GraphQLStoreCartDiscountsLimitReachedError buildUnchecked() { 177 return new GraphQLStoreCartDiscountsLimitReachedErrorImpl(values, stores); 178 } 179 180 /** 181 * factory method for an instance of GraphQLStoreCartDiscountsLimitReachedErrorBuilder 182 * @return builder 183 */ 184 public static GraphQLStoreCartDiscountsLimitReachedErrorBuilder of() { 185 return new GraphQLStoreCartDiscountsLimitReachedErrorBuilder(); 186 } 187 188 /** 189 * create builder for GraphQLStoreCartDiscountsLimitReachedError instance 190 * @param template instance with prefilled values for the builder 191 * @return builder 192 */ 193 public static GraphQLStoreCartDiscountsLimitReachedErrorBuilder of( 194 final GraphQLStoreCartDiscountsLimitReachedError template) { 195 GraphQLStoreCartDiscountsLimitReachedErrorBuilder builder = new GraphQLStoreCartDiscountsLimitReachedErrorBuilder(); 196 builder.values = template.values(); 197 builder.stores = template.getStores(); 198 return builder; 199 } 200 201}