001 002package com.commercetools.history.models.label; 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 * ProductLabelBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * ProductLabel productLabel = ProductLabel.builder() 017 * .slug(slugBuilder -> slugBuilder) 018 * .name(nameBuilder -> nameBuilder) 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 ProductLabelBuilder implements Builder<ProductLabel> { 025 026 private com.commercetools.history.models.common.LocalizedString slug; 027 028 private com.commercetools.history.models.common.LocalizedString name; 029 030 /** 031 * <p>User-defined identifier used in a deep-link URL for the Product.</p> 032 * @param builder function to build the slug value 033 * @return Builder 034 */ 035 036 public ProductLabelBuilder slug( 037 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedStringBuilder> builder) { 038 this.slug = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()).build(); 039 return this; 040 } 041 042 /** 043 * <p>User-defined identifier used in a deep-link URL for the Product.</p> 044 * @param builder function to build the slug value 045 * @return Builder 046 */ 047 048 public ProductLabelBuilder withSlug( 049 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedString> builder) { 050 this.slug = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()); 051 return this; 052 } 053 054 /** 055 * <p>User-defined identifier used in a deep-link URL for the Product.</p> 056 * @param slug value to be set 057 * @return Builder 058 */ 059 060 public ProductLabelBuilder slug(final com.commercetools.history.models.common.LocalizedString slug) { 061 this.slug = slug; 062 return this; 063 } 064 065 /** 066 * <p>Name of the Product.</p> 067 * @param builder function to build the name value 068 * @return Builder 069 */ 070 071 public ProductLabelBuilder name( 072 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedStringBuilder> builder) { 073 this.name = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()).build(); 074 return this; 075 } 076 077 /** 078 * <p>Name of the Product.</p> 079 * @param builder function to build the name value 080 * @return Builder 081 */ 082 083 public ProductLabelBuilder withName( 084 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedString> builder) { 085 this.name = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()); 086 return this; 087 } 088 089 /** 090 * <p>Name of the Product.</p> 091 * @param name value to be set 092 * @return Builder 093 */ 094 095 public ProductLabelBuilder name(final com.commercetools.history.models.common.LocalizedString name) { 096 this.name = name; 097 return this; 098 } 099 100 /** 101 * <p>User-defined identifier used in a deep-link URL for the Product.</p> 102 * @return slug 103 */ 104 105 public com.commercetools.history.models.common.LocalizedString getSlug() { 106 return this.slug; 107 } 108 109 /** 110 * <p>Name of the Product.</p> 111 * @return name 112 */ 113 114 public com.commercetools.history.models.common.LocalizedString getName() { 115 return this.name; 116 } 117 118 /** 119 * builds ProductLabel with checking for non-null required values 120 * @return ProductLabel 121 */ 122 public ProductLabel build() { 123 Objects.requireNonNull(slug, ProductLabel.class + ": slug is missing"); 124 Objects.requireNonNull(name, ProductLabel.class + ": name is missing"); 125 return new ProductLabelImpl(slug, name); 126 } 127 128 /** 129 * builds ProductLabel without checking for non-null required values 130 * @return ProductLabel 131 */ 132 public ProductLabel buildUnchecked() { 133 return new ProductLabelImpl(slug, name); 134 } 135 136 /** 137 * factory method for an instance of ProductLabelBuilder 138 * @return builder 139 */ 140 public static ProductLabelBuilder of() { 141 return new ProductLabelBuilder(); 142 } 143 144 /** 145 * create builder for ProductLabel instance 146 * @param template instance with prefilled values for the builder 147 * @return builder 148 */ 149 public static ProductLabelBuilder of(final ProductLabel template) { 150 ProductLabelBuilder builder = new ProductLabelBuilder(); 151 builder.slug = template.getSlug(); 152 builder.name = template.getName(); 153 return builder; 154 } 155 156}