001 002package com.commercetools.api.models.associate_role; 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 * AssociateRoleDraftBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * AssociateRoleDraft associateRoleDraft = AssociateRoleDraft.builder() 019 * .key("{key}") 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 AssociateRoleDraftBuilder implements Builder<AssociateRoleDraft> { 026 027 private String key; 028 029 @Nullable 030 private String name; 031 032 @Nullable 033 private Boolean buyerAssignable; 034 035 @Nullable 036 private java.util.List<com.commercetools.api.models.associate_role.Permission> permissions; 037 038 @Nullable 039 private com.commercetools.api.models.type.CustomFieldsDraft custom; 040 041 /** 042 * <p>User-defined unique identifier for the AssociateRole.</p> 043 * @param key value to be set 044 * @return Builder 045 */ 046 047 public AssociateRoleDraftBuilder key(final String key) { 048 this.key = key; 049 return this; 050 } 051 052 /** 053 * <p>Name of the AssociateRole.</p> 054 * @param name value to be set 055 * @return Builder 056 */ 057 058 public AssociateRoleDraftBuilder name(@Nullable final String name) { 059 this.name = name; 060 return this; 061 } 062 063 /** 064 * <p>Whether the AssociateRole can be assigned to an Associate by a buyer.</p> 065 * @param buyerAssignable value to be set 066 * @return Builder 067 */ 068 069 public AssociateRoleDraftBuilder buyerAssignable(@Nullable final Boolean buyerAssignable) { 070 this.buyerAssignable = buyerAssignable; 071 return this; 072 } 073 074 /** 075 * <p>List of Permissions for the AssociateRole.</p> 076 * @param permissions value to be set 077 * @return Builder 078 */ 079 080 public AssociateRoleDraftBuilder permissions( 081 @Nullable final com.commercetools.api.models.associate_role.Permission... permissions) { 082 this.permissions = new ArrayList<>(Arrays.asList(permissions)); 083 return this; 084 } 085 086 /** 087 * <p>List of Permissions for the AssociateRole.</p> 088 * @param permissions value to be set 089 * @return Builder 090 */ 091 092 public AssociateRoleDraftBuilder permissions( 093 @Nullable final java.util.List<com.commercetools.api.models.associate_role.Permission> permissions) { 094 this.permissions = permissions; 095 return this; 096 } 097 098 /** 099 * <p>List of Permissions for the AssociateRole.</p> 100 * @param permissions value to be set 101 * @return Builder 102 */ 103 104 public AssociateRoleDraftBuilder plusPermissions( 105 @Nullable final com.commercetools.api.models.associate_role.Permission... permissions) { 106 if (this.permissions == null) { 107 this.permissions = new ArrayList<>(); 108 } 109 this.permissions.addAll(Arrays.asList(permissions)); 110 return this; 111 } 112 113 /** 114 * <p>Custom Fields for the AssociateRole.</p> 115 * @param builder function to build the custom value 116 * @return Builder 117 */ 118 119 public AssociateRoleDraftBuilder custom( 120 Function<com.commercetools.api.models.type.CustomFieldsDraftBuilder, com.commercetools.api.models.type.CustomFieldsDraftBuilder> builder) { 121 this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsDraftBuilder.of()).build(); 122 return this; 123 } 124 125 /** 126 * <p>Custom Fields for the AssociateRole.</p> 127 * @param builder function to build the custom value 128 * @return Builder 129 */ 130 131 public AssociateRoleDraftBuilder withCustom( 132 Function<com.commercetools.api.models.type.CustomFieldsDraftBuilder, com.commercetools.api.models.type.CustomFieldsDraft> builder) { 133 this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsDraftBuilder.of()); 134 return this; 135 } 136 137 /** 138 * <p>Custom Fields for the AssociateRole.</p> 139 * @param custom value to be set 140 * @return Builder 141 */ 142 143 public AssociateRoleDraftBuilder custom( 144 @Nullable final com.commercetools.api.models.type.CustomFieldsDraft custom) { 145 this.custom = custom; 146 return this; 147 } 148 149 /** 150 * <p>User-defined unique identifier for the AssociateRole.</p> 151 * @return key 152 */ 153 154 public String getKey() { 155 return this.key; 156 } 157 158 /** 159 * <p>Name of the AssociateRole.</p> 160 * @return name 161 */ 162 163 @Nullable 164 public String getName() { 165 return this.name; 166 } 167 168 /** 169 * <p>Whether the AssociateRole can be assigned to an Associate by a buyer.</p> 170 * @return buyerAssignable 171 */ 172 173 @Nullable 174 public Boolean getBuyerAssignable() { 175 return this.buyerAssignable; 176 } 177 178 /** 179 * <p>List of Permissions for the AssociateRole.</p> 180 * @return permissions 181 */ 182 183 @Nullable 184 public java.util.List<com.commercetools.api.models.associate_role.Permission> getPermissions() { 185 return this.permissions; 186 } 187 188 /** 189 * <p>Custom Fields for the AssociateRole.</p> 190 * @return custom 191 */ 192 193 @Nullable 194 public com.commercetools.api.models.type.CustomFieldsDraft getCustom() { 195 return this.custom; 196 } 197 198 /** 199 * builds AssociateRoleDraft with checking for non-null required values 200 * @return AssociateRoleDraft 201 */ 202 public AssociateRoleDraft build() { 203 Objects.requireNonNull(key, AssociateRoleDraft.class + ": key is missing"); 204 return new AssociateRoleDraftImpl(key, name, buyerAssignable, permissions, custom); 205 } 206 207 /** 208 * builds AssociateRoleDraft without checking for non-null required values 209 * @return AssociateRoleDraft 210 */ 211 public AssociateRoleDraft buildUnchecked() { 212 return new AssociateRoleDraftImpl(key, name, buyerAssignable, permissions, custom); 213 } 214 215 /** 216 * factory method for an instance of AssociateRoleDraftBuilder 217 * @return builder 218 */ 219 public static AssociateRoleDraftBuilder of() { 220 return new AssociateRoleDraftBuilder(); 221 } 222 223 /** 224 * create builder for AssociateRoleDraft instance 225 * @param template instance with prefilled values for the builder 226 * @return builder 227 */ 228 public static AssociateRoleDraftBuilder of(final AssociateRoleDraft template) { 229 AssociateRoleDraftBuilder builder = new AssociateRoleDraftBuilder(); 230 builder.key = template.getKey(); 231 builder.name = template.getName(); 232 builder.buyerAssignable = template.getBuyerAssignable(); 233 builder.permissions = template.getPermissions(); 234 builder.custom = template.getCustom(); 235 return builder; 236 } 237 238}