001 002package com.commercetools.api.models.shipping_method; 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 * ShippingMethodReferenceBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * ShippingMethodReference shippingMethodReference = ShippingMethodReference.builder() 019 * .id("{id}") 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 ShippingMethodReferenceBuilder implements Builder<ShippingMethodReference> { 026 027 private String id; 028 029 @Nullable 030 private com.commercetools.api.models.shipping_method.ShippingMethod obj; 031 032 /** 033 * <p>Unique identifier of the referenced ShippingMethod.</p> 034 * @param id value to be set 035 * @return Builder 036 */ 037 038 public ShippingMethodReferenceBuilder id(final String id) { 039 this.id = id; 040 return this; 041 } 042 043 /** 044 * <p>Contains the representation of the expanded ShippingMethod. Only present in responses to requests with Reference Expansion for ShippingMethods.</p> 045 * @param builder function to build the obj value 046 * @return Builder 047 */ 048 049 public ShippingMethodReferenceBuilder obj( 050 Function<com.commercetools.api.models.shipping_method.ShippingMethodBuilder, com.commercetools.api.models.shipping_method.ShippingMethodBuilder> builder) { 051 this.obj = builder.apply(com.commercetools.api.models.shipping_method.ShippingMethodBuilder.of()).build(); 052 return this; 053 } 054 055 /** 056 * <p>Contains the representation of the expanded ShippingMethod. Only present in responses to requests with Reference Expansion for ShippingMethods.</p> 057 * @param builder function to build the obj value 058 * @return Builder 059 */ 060 061 public ShippingMethodReferenceBuilder withObj( 062 Function<com.commercetools.api.models.shipping_method.ShippingMethodBuilder, com.commercetools.api.models.shipping_method.ShippingMethod> builder) { 063 this.obj = builder.apply(com.commercetools.api.models.shipping_method.ShippingMethodBuilder.of()); 064 return this; 065 } 066 067 /** 068 * <p>Contains the representation of the expanded ShippingMethod. Only present in responses to requests with Reference Expansion for ShippingMethods.</p> 069 * @param obj value to be set 070 * @return Builder 071 */ 072 073 public ShippingMethodReferenceBuilder obj( 074 @Nullable final com.commercetools.api.models.shipping_method.ShippingMethod obj) { 075 this.obj = obj; 076 return this; 077 } 078 079 /** 080 * <p>Unique identifier of the referenced ShippingMethod.</p> 081 * @return id 082 */ 083 084 public String getId() { 085 return this.id; 086 } 087 088 /** 089 * <p>Contains the representation of the expanded ShippingMethod. Only present in responses to requests with Reference Expansion for ShippingMethods.</p> 090 * @return obj 091 */ 092 093 @Nullable 094 public com.commercetools.api.models.shipping_method.ShippingMethod getObj() { 095 return this.obj; 096 } 097 098 /** 099 * builds ShippingMethodReference with checking for non-null required values 100 * @return ShippingMethodReference 101 */ 102 public ShippingMethodReference build() { 103 Objects.requireNonNull(id, ShippingMethodReference.class + ": id is missing"); 104 return new ShippingMethodReferenceImpl(id, obj); 105 } 106 107 /** 108 * builds ShippingMethodReference without checking for non-null required values 109 * @return ShippingMethodReference 110 */ 111 public ShippingMethodReference buildUnchecked() { 112 return new ShippingMethodReferenceImpl(id, obj); 113 } 114 115 /** 116 * factory method for an instance of ShippingMethodReferenceBuilder 117 * @return builder 118 */ 119 public static ShippingMethodReferenceBuilder of() { 120 return new ShippingMethodReferenceBuilder(); 121 } 122 123 /** 124 * create builder for ShippingMethodReference instance 125 * @param template instance with prefilled values for the builder 126 * @return builder 127 */ 128 public static ShippingMethodReferenceBuilder of(final ShippingMethodReference template) { 129 ShippingMethodReferenceBuilder builder = new ShippingMethodReferenceBuilder(); 130 builder.id = template.getId(); 131 builder.obj = template.getObj(); 132 return builder; 133 } 134 135}