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