001 002package com.commercetools.history.models.common; 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 * AssociateBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * Associate associate = Associate.builder() 017 * .plusAssociateRoleAssignments(associateRoleAssignmentsBuilder -> associateRoleAssignmentsBuilder) 018 * .customer(customerBuilder -> customerBuilder) 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 AssociateBuilder implements Builder<Associate> { 025 026 private java.util.List<com.commercetools.history.models.common.AssociateRoleAssignment> associateRoleAssignments; 027 028 private com.commercetools.history.models.common.Reference customer; 029 030 /** 031 * set values to the associateRoleAssignments 032 * @param associateRoleAssignments value to be set 033 * @return Builder 034 */ 035 036 public AssociateBuilder associateRoleAssignments( 037 final com.commercetools.history.models.common.AssociateRoleAssignment... associateRoleAssignments) { 038 this.associateRoleAssignments = new ArrayList<>(Arrays.asList(associateRoleAssignments)); 039 return this; 040 } 041 042 /** 043 * set value to the associateRoleAssignments 044 * @param associateRoleAssignments value to be set 045 * @return Builder 046 */ 047 048 public AssociateBuilder associateRoleAssignments( 049 final java.util.List<com.commercetools.history.models.common.AssociateRoleAssignment> associateRoleAssignments) { 050 this.associateRoleAssignments = associateRoleAssignments; 051 return this; 052 } 053 054 /** 055 * add values to the associateRoleAssignments 056 * @param associateRoleAssignments value to be set 057 * @return Builder 058 */ 059 060 public AssociateBuilder plusAssociateRoleAssignments( 061 final com.commercetools.history.models.common.AssociateRoleAssignment... associateRoleAssignments) { 062 if (this.associateRoleAssignments == null) { 063 this.associateRoleAssignments = new ArrayList<>(); 064 } 065 this.associateRoleAssignments.addAll(Arrays.asList(associateRoleAssignments)); 066 return this; 067 } 068 069 /** 070 * add the value to the associateRoleAssignments using the builder function 071 * @param builder function to build the associateRoleAssignments value 072 * @return Builder 073 */ 074 075 public AssociateBuilder plusAssociateRoleAssignments( 076 Function<com.commercetools.history.models.common.AssociateRoleAssignmentBuilder, com.commercetools.history.models.common.AssociateRoleAssignmentBuilder> builder) { 077 if (this.associateRoleAssignments == null) { 078 this.associateRoleAssignments = new ArrayList<>(); 079 } 080 this.associateRoleAssignments.add( 081 builder.apply(com.commercetools.history.models.common.AssociateRoleAssignmentBuilder.of()).build()); 082 return this; 083 } 084 085 /** 086 * set the value to the associateRoleAssignments using the builder function 087 * @param builder function to build the associateRoleAssignments value 088 * @return Builder 089 */ 090 091 public AssociateBuilder withAssociateRoleAssignments( 092 Function<com.commercetools.history.models.common.AssociateRoleAssignmentBuilder, com.commercetools.history.models.common.AssociateRoleAssignmentBuilder> builder) { 093 this.associateRoleAssignments = new ArrayList<>(); 094 this.associateRoleAssignments.add( 095 builder.apply(com.commercetools.history.models.common.AssociateRoleAssignmentBuilder.of()).build()); 096 return this; 097 } 098 099 /** 100 * add the value to the associateRoleAssignments using the builder function 101 * @param builder function to build the associateRoleAssignments value 102 * @return Builder 103 */ 104 105 public AssociateBuilder addAssociateRoleAssignments( 106 Function<com.commercetools.history.models.common.AssociateRoleAssignmentBuilder, com.commercetools.history.models.common.AssociateRoleAssignment> builder) { 107 return plusAssociateRoleAssignments( 108 builder.apply(com.commercetools.history.models.common.AssociateRoleAssignmentBuilder.of())); 109 } 110 111 /** 112 * set the value to the associateRoleAssignments using the builder function 113 * @param builder function to build the associateRoleAssignments value 114 * @return Builder 115 */ 116 117 public AssociateBuilder setAssociateRoleAssignments( 118 Function<com.commercetools.history.models.common.AssociateRoleAssignmentBuilder, com.commercetools.history.models.common.AssociateRoleAssignment> builder) { 119 return associateRoleAssignments( 120 builder.apply(com.commercetools.history.models.common.AssociateRoleAssignmentBuilder.of())); 121 } 122 123 /** 124 * set the value to the customer using the builder function 125 * @param builder function to build the customer value 126 * @return Builder 127 */ 128 129 public AssociateBuilder customer( 130 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.ReferenceBuilder> builder) { 131 this.customer = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()).build(); 132 return this; 133 } 134 135 /** 136 * set the value to the customer using the builder function 137 * @param builder function to build the customer value 138 * @return Builder 139 */ 140 141 public AssociateBuilder withCustomer( 142 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.Reference> builder) { 143 this.customer = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()); 144 return this; 145 } 146 147 /** 148 * set the value to the customer 149 * @param customer value to be set 150 * @return Builder 151 */ 152 153 public AssociateBuilder customer(final com.commercetools.history.models.common.Reference customer) { 154 this.customer = customer; 155 return this; 156 } 157 158 /** 159 * value of associateRoleAssignments} 160 * @return associateRoleAssignments 161 */ 162 163 public java.util.List<com.commercetools.history.models.common.AssociateRoleAssignment> getAssociateRoleAssignments() { 164 return this.associateRoleAssignments; 165 } 166 167 /** 168 * value of customer} 169 * @return customer 170 */ 171 172 public com.commercetools.history.models.common.Reference getCustomer() { 173 return this.customer; 174 } 175 176 /** 177 * builds Associate with checking for non-null required values 178 * @return Associate 179 */ 180 public Associate build() { 181 Objects.requireNonNull(associateRoleAssignments, Associate.class + ": associateRoleAssignments is missing"); 182 Objects.requireNonNull(customer, Associate.class + ": customer is missing"); 183 return new AssociateImpl(associateRoleAssignments, customer); 184 } 185 186 /** 187 * builds Associate without checking for non-null required values 188 * @return Associate 189 */ 190 public Associate buildUnchecked() { 191 return new AssociateImpl(associateRoleAssignments, customer); 192 } 193 194 /** 195 * factory method for an instance of AssociateBuilder 196 * @return builder 197 */ 198 public static AssociateBuilder of() { 199 return new AssociateBuilder(); 200 } 201 202 /** 203 * create builder for Associate instance 204 * @param template instance with prefilled values for the builder 205 * @return builder 206 */ 207 public static AssociateBuilder of(final Associate template) { 208 AssociateBuilder builder = new AssociateBuilder(); 209 builder.associateRoleAssignments = template.getAssociateRoleAssignments(); 210 builder.customer = template.getCustomer(); 211 return builder; 212 } 213 214}