001 002package com.commercetools.history.models.common; 003 004import java.util.*; 005 006import io.vrap.rmf.base.client.Builder; 007import io.vrap.rmf.base.client.utils.Generated; 008 009/** 010 * VariantBuilder 011 * <hr> 012 * Example to create an instance using the builder pattern 013 * <div class=code-example> 014 * <pre><code class='java'> 015 * Variant variant = Variant.builder() 016 * .id(1) 017 * .sku("{sku}") 018 * .key("{key}") 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 VariantBuilder implements Builder<Variant> { 025 026 private Integer id; 027 028 private String sku; 029 030 private String key; 031 032 /** 033 * set the value to the id 034 * @param id value to be set 035 * @return Builder 036 */ 037 038 public VariantBuilder id(final Integer id) { 039 this.id = id; 040 return this; 041 } 042 043 /** 044 * set the value to the sku 045 * @param sku value to be set 046 * @return Builder 047 */ 048 049 public VariantBuilder sku(final String sku) { 050 this.sku = sku; 051 return this; 052 } 053 054 /** 055 * set the value to the key 056 * @param key value to be set 057 * @return Builder 058 */ 059 060 public VariantBuilder key(final String key) { 061 this.key = key; 062 return this; 063 } 064 065 /** 066 * value of id} 067 * @return id 068 */ 069 070 public Integer getId() { 071 return this.id; 072 } 073 074 /** 075 * value of sku} 076 * @return sku 077 */ 078 079 public String getSku() { 080 return this.sku; 081 } 082 083 /** 084 * value of key} 085 * @return key 086 */ 087 088 public String getKey() { 089 return this.key; 090 } 091 092 /** 093 * builds Variant with checking for non-null required values 094 * @return Variant 095 */ 096 public Variant build() { 097 Objects.requireNonNull(id, Variant.class + ": id is missing"); 098 Objects.requireNonNull(sku, Variant.class + ": sku is missing"); 099 Objects.requireNonNull(key, Variant.class + ": key is missing"); 100 return new VariantImpl(id, sku, key); 101 } 102 103 /** 104 * builds Variant without checking for non-null required values 105 * @return Variant 106 */ 107 public Variant buildUnchecked() { 108 return new VariantImpl(id, sku, key); 109 } 110 111 /** 112 * factory method for an instance of VariantBuilder 113 * @return builder 114 */ 115 public static VariantBuilder of() { 116 return new VariantBuilder(); 117 } 118 119 /** 120 * create builder for Variant instance 121 * @param template instance with prefilled values for the builder 122 * @return builder 123 */ 124 public static VariantBuilder of(final Variant template) { 125 VariantBuilder builder = new VariantBuilder(); 126 builder.id = template.getId(); 127 builder.sku = template.getSku(); 128 builder.key = template.getKey(); 129 return builder; 130 } 131 132}