001 002package com.commercetools.api.models.error; 003 004import java.util.*; 005import java.util.function.Function; 006 007import javax.annotation.Nullable; 008 009import io.vrap.rmf.base.client.Builder; 010import io.vrap.rmf.base.client.utils.Generated; 011 012/** 013 * AssociateMissingPermissionErrorBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * AssociateMissingPermissionError associateMissingPermissionError = AssociateMissingPermissionError.builder() 019 * .message("{message}") 020 * .associate(associateBuilder -> associateBuilder) 021 * .businessUnit(businessUnitBuilder -> businessUnitBuilder) 022 * .plusPermissions(permissionsBuilder -> permissionsBuilder) 023 * .build() 024 * </code></pre> 025 * </div> 026 */ 027@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 028public class AssociateMissingPermissionErrorBuilder implements Builder<AssociateMissingPermissionError> { 029 030 private String message; 031 032 private Map<String, java.lang.Object> values = new HashMap<>(); 033 034 private com.commercetools.api.models.customer.CustomerResourceIdentifier associate; 035 036 private com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifier businessUnit; 037 038 @Nullable 039 private com.commercetools.api.models.customer.CustomerResourceIdentifier associateOnBehalf; 040 041 private java.util.List<com.commercetools.api.models.associate_role.Permission> permissions; 042 043 /** 044 * <ul> 045 * <li>When an action is performed by an Associate: <code>"Associate '$idOfAssociate' has no rights to $action in business-unit '$idOrKeyOfBusinessUnit'. Needs '$requiredPermission'."</code></li> 046 * <li>When an action is performed for another Associate, like viewing their Cart: <code>"Associate '$idOfAssociate' has no rights to $action for customer '$idOfCustomer' in business-unit '$idOrKeyOfBusinessUnit'. Needs '$requiredPermission'."</code></li> 047 * <li>When viewing an entity: <code>"Associate '$idOfAssociate' has no rights to $action in business-unit '$idOrKeyOfBusinessUnit'. Needs '$requiredViewMyPermission' or '$requiredViewOthersPermission'."</code></li> 048 * </ul> 049 * @param message value to be set 050 * @return Builder 051 */ 052 053 public AssociateMissingPermissionErrorBuilder message(final String message) { 054 this.message = message; 055 return this; 056 } 057 058 /** 059 * <p>Error-specific additional fields.</p> 060 * @param values properties to be set 061 * @return Builder 062 */ 063 064 public AssociateMissingPermissionErrorBuilder values(final Map<String, java.lang.Object> values) { 065 this.values = values; 066 return this; 067 } 068 069 /** 070 * <p>Error-specific additional fields.</p> 071 * @param key property name 072 * @param value property value 073 * @return Builder 074 */ 075 076 public AssociateMissingPermissionErrorBuilder addValue(final String key, final java.lang.Object value) { 077 if (this.values == null) { 078 values = new HashMap<>(); 079 } 080 values.put(key, value); 081 return this; 082 } 083 084 /** 085 * <p>ResourceIdentifier to the Associate that tried to perform the action.</p> 086 * @param builder function to build the associate value 087 * @return Builder 088 */ 089 090 public AssociateMissingPermissionErrorBuilder associate( 091 Function<com.commercetools.api.models.customer.CustomerResourceIdentifierBuilder, com.commercetools.api.models.customer.CustomerResourceIdentifierBuilder> builder) { 092 this.associate = builder.apply(com.commercetools.api.models.customer.CustomerResourceIdentifierBuilder.of()) 093 .build(); 094 return this; 095 } 096 097 /** 098 * <p>ResourceIdentifier to the Associate that tried to perform the action.</p> 099 * @param builder function to build the associate value 100 * @return Builder 101 */ 102 103 public AssociateMissingPermissionErrorBuilder withAssociate( 104 Function<com.commercetools.api.models.customer.CustomerResourceIdentifierBuilder, com.commercetools.api.models.customer.CustomerResourceIdentifier> builder) { 105 this.associate = builder.apply(com.commercetools.api.models.customer.CustomerResourceIdentifierBuilder.of()); 106 return this; 107 } 108 109 /** 110 * <p>ResourceIdentifier to the Associate that tried to perform the action.</p> 111 * @param associate value to be set 112 * @return Builder 113 */ 114 115 public AssociateMissingPermissionErrorBuilder associate( 116 final com.commercetools.api.models.customer.CustomerResourceIdentifier associate) { 117 this.associate = associate; 118 return this; 119 } 120 121 /** 122 * <p>ResourceIdentifier to the BusinessUnit.</p> 123 * @param builder function to build the businessUnit value 124 * @return Builder 125 */ 126 127 public AssociateMissingPermissionErrorBuilder businessUnit( 128 Function<com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifierBuilder, com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifierBuilder> builder) { 129 this.businessUnit = builder 130 .apply(com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifierBuilder.of()) 131 .build(); 132 return this; 133 } 134 135 /** 136 * <p>ResourceIdentifier to the BusinessUnit.</p> 137 * @param builder function to build the businessUnit value 138 * @return Builder 139 */ 140 141 public AssociateMissingPermissionErrorBuilder withBusinessUnit( 142 Function<com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifierBuilder, com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifier> builder) { 143 this.businessUnit = builder 144 .apply(com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifierBuilder.of()); 145 return this; 146 } 147 148 /** 149 * <p>ResourceIdentifier to the BusinessUnit.</p> 150 * @param businessUnit value to be set 151 * @return Builder 152 */ 153 154 public AssociateMissingPermissionErrorBuilder businessUnit( 155 final com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifier businessUnit) { 156 this.businessUnit = businessUnit; 157 return this; 158 } 159 160 /** 161 * <p>ResourceIdentifier of the Associate on whose behalf the action is performed.</p> 162 * @param builder function to build the associateOnBehalf value 163 * @return Builder 164 */ 165 166 public AssociateMissingPermissionErrorBuilder associateOnBehalf( 167 Function<com.commercetools.api.models.customer.CustomerResourceIdentifierBuilder, com.commercetools.api.models.customer.CustomerResourceIdentifierBuilder> builder) { 168 this.associateOnBehalf = builder 169 .apply(com.commercetools.api.models.customer.CustomerResourceIdentifierBuilder.of()) 170 .build(); 171 return this; 172 } 173 174 /** 175 * <p>ResourceIdentifier of the Associate on whose behalf the action is performed.</p> 176 * @param builder function to build the associateOnBehalf value 177 * @return Builder 178 */ 179 180 public AssociateMissingPermissionErrorBuilder withAssociateOnBehalf( 181 Function<com.commercetools.api.models.customer.CustomerResourceIdentifierBuilder, com.commercetools.api.models.customer.CustomerResourceIdentifier> builder) { 182 this.associateOnBehalf = builder 183 .apply(com.commercetools.api.models.customer.CustomerResourceIdentifierBuilder.of()); 184 return this; 185 } 186 187 /** 188 * <p>ResourceIdentifier of the Associate on whose behalf the action is performed.</p> 189 * @param associateOnBehalf value to be set 190 * @return Builder 191 */ 192 193 public AssociateMissingPermissionErrorBuilder associateOnBehalf( 194 @Nullable final com.commercetools.api.models.customer.CustomerResourceIdentifier associateOnBehalf) { 195 this.associateOnBehalf = associateOnBehalf; 196 return this; 197 } 198 199 /** 200 * <p>The Permissions that the Associate performing the action lacks. At least one of these Permissions is needed.</p> 201 * @param permissions value to be set 202 * @return Builder 203 */ 204 205 public AssociateMissingPermissionErrorBuilder permissions( 206 final com.commercetools.api.models.associate_role.Permission... permissions) { 207 this.permissions = new ArrayList<>(Arrays.asList(permissions)); 208 return this; 209 } 210 211 /** 212 * <p>The Permissions that the Associate performing the action lacks. At least one of these Permissions is needed.</p> 213 * @param permissions value to be set 214 * @return Builder 215 */ 216 217 public AssociateMissingPermissionErrorBuilder permissions( 218 final java.util.List<com.commercetools.api.models.associate_role.Permission> permissions) { 219 this.permissions = permissions; 220 return this; 221 } 222 223 /** 224 * <p>The Permissions that the Associate performing the action lacks. At least one of these Permissions is needed.</p> 225 * @param permissions value to be set 226 * @return Builder 227 */ 228 229 public AssociateMissingPermissionErrorBuilder plusPermissions( 230 final com.commercetools.api.models.associate_role.Permission... permissions) { 231 if (this.permissions == null) { 232 this.permissions = new ArrayList<>(); 233 } 234 this.permissions.addAll(Arrays.asList(permissions)); 235 return this; 236 } 237 238 /** 239 * <ul> 240 * <li>When an action is performed by an Associate: <code>"Associate '$idOfAssociate' has no rights to $action in business-unit '$idOrKeyOfBusinessUnit'. Needs '$requiredPermission'."</code></li> 241 * <li>When an action is performed for another Associate, like viewing their Cart: <code>"Associate '$idOfAssociate' has no rights to $action for customer '$idOfCustomer' in business-unit '$idOrKeyOfBusinessUnit'. Needs '$requiredPermission'."</code></li> 242 * <li>When viewing an entity: <code>"Associate '$idOfAssociate' has no rights to $action in business-unit '$idOrKeyOfBusinessUnit'. Needs '$requiredViewMyPermission' or '$requiredViewOthersPermission'."</code></li> 243 * </ul> 244 * @return message 245 */ 246 247 public String getMessage() { 248 return this.message; 249 } 250 251 /** 252 * <p>Error-specific additional fields.</p> 253 * @return pattern properties 254 */ 255 256 public Map<String, java.lang.Object> getValues() { 257 return this.values; 258 } 259 260 /** 261 * <p>ResourceIdentifier to the Associate that tried to perform the action.</p> 262 * @return associate 263 */ 264 265 public com.commercetools.api.models.customer.CustomerResourceIdentifier getAssociate() { 266 return this.associate; 267 } 268 269 /** 270 * <p>ResourceIdentifier to the BusinessUnit.</p> 271 * @return businessUnit 272 */ 273 274 public com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifier getBusinessUnit() { 275 return this.businessUnit; 276 } 277 278 /** 279 * <p>ResourceIdentifier of the Associate on whose behalf the action is performed.</p> 280 * @return associateOnBehalf 281 */ 282 283 @Nullable 284 public com.commercetools.api.models.customer.CustomerResourceIdentifier getAssociateOnBehalf() { 285 return this.associateOnBehalf; 286 } 287 288 /** 289 * <p>The Permissions that the Associate performing the action lacks. At least one of these Permissions is needed.</p> 290 * @return permissions 291 */ 292 293 public java.util.List<com.commercetools.api.models.associate_role.Permission> getPermissions() { 294 return this.permissions; 295 } 296 297 /** 298 * builds AssociateMissingPermissionError with checking for non-null required values 299 * @return AssociateMissingPermissionError 300 */ 301 public AssociateMissingPermissionError build() { 302 Objects.requireNonNull(message, AssociateMissingPermissionError.class + ": message is missing"); 303 Objects.requireNonNull(associate, AssociateMissingPermissionError.class + ": associate is missing"); 304 Objects.requireNonNull(businessUnit, AssociateMissingPermissionError.class + ": businessUnit is missing"); 305 Objects.requireNonNull(permissions, AssociateMissingPermissionError.class + ": permissions is missing"); 306 return new AssociateMissingPermissionErrorImpl(message, values, associate, businessUnit, associateOnBehalf, 307 permissions); 308 } 309 310 /** 311 * builds AssociateMissingPermissionError without checking for non-null required values 312 * @return AssociateMissingPermissionError 313 */ 314 public AssociateMissingPermissionError buildUnchecked() { 315 return new AssociateMissingPermissionErrorImpl(message, values, associate, businessUnit, associateOnBehalf, 316 permissions); 317 } 318 319 /** 320 * factory method for an instance of AssociateMissingPermissionErrorBuilder 321 * @return builder 322 */ 323 public static AssociateMissingPermissionErrorBuilder of() { 324 return new AssociateMissingPermissionErrorBuilder(); 325 } 326 327 /** 328 * create builder for AssociateMissingPermissionError instance 329 * @param template instance with prefilled values for the builder 330 * @return builder 331 */ 332 public static AssociateMissingPermissionErrorBuilder of(final AssociateMissingPermissionError template) { 333 AssociateMissingPermissionErrorBuilder builder = new AssociateMissingPermissionErrorBuilder(); 334 builder.message = template.getMessage(); 335 builder.values = template.values(); 336 builder.associate = template.getAssociate(); 337 builder.businessUnit = template.getBusinessUnit(); 338 builder.associateOnBehalf = template.getAssociateOnBehalf(); 339 builder.permissions = template.getPermissions(); 340 return builder; 341 } 342 343}