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 * CustomFieldsBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * CustomFields customFields = CustomFields.builder() 017 * .type(typeBuilder -> typeBuilder) 018 * .fields(fieldsBuilder -> fieldsBuilder) 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 CustomFieldsBuilder implements Builder<CustomFields> { 025 026 private com.commercetools.history.models.common.Reference type; 027 028 private java.lang.Object fields; 029 030 /** 031 * set the value to the type using the builder function 032 * @param builder function to build the type value 033 * @return Builder 034 */ 035 036 public CustomFieldsBuilder type( 037 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.ReferenceBuilder> builder) { 038 this.type = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()).build(); 039 return this; 040 } 041 042 /** 043 * set the value to the type using the builder function 044 * @param builder function to build the type value 045 * @return Builder 046 */ 047 048 public CustomFieldsBuilder withType( 049 Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.Reference> builder) { 050 this.type = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()); 051 return this; 052 } 053 054 /** 055 * set the value to the type 056 * @param type value to be set 057 * @return Builder 058 */ 059 060 public CustomFieldsBuilder type(final com.commercetools.history.models.common.Reference type) { 061 this.type = type; 062 return this; 063 } 064 065 /** 066 * <p>A valid JSON object, based on FieldDefinition.</p> 067 * @param fields value to be set 068 * @return Builder 069 */ 070 071 public CustomFieldsBuilder fields(final java.lang.Object fields) { 072 this.fields = fields; 073 return this; 074 } 075 076 /** 077 * value of type} 078 * @return type 079 */ 080 081 public com.commercetools.history.models.common.Reference getType() { 082 return this.type; 083 } 084 085 /** 086 * <p>A valid JSON object, based on FieldDefinition.</p> 087 * @return fields 088 */ 089 090 public java.lang.Object getFields() { 091 return this.fields; 092 } 093 094 /** 095 * builds CustomFields with checking for non-null required values 096 * @return CustomFields 097 */ 098 public CustomFields build() { 099 Objects.requireNonNull(type, CustomFields.class + ": type is missing"); 100 Objects.requireNonNull(fields, CustomFields.class + ": fields is missing"); 101 return new CustomFieldsImpl(type, fields); 102 } 103 104 /** 105 * builds CustomFields without checking for non-null required values 106 * @return CustomFields 107 */ 108 public CustomFields buildUnchecked() { 109 return new CustomFieldsImpl(type, fields); 110 } 111 112 /** 113 * factory method for an instance of CustomFieldsBuilder 114 * @return builder 115 */ 116 public static CustomFieldsBuilder of() { 117 return new CustomFieldsBuilder(); 118 } 119 120 /** 121 * create builder for CustomFields instance 122 * @param template instance with prefilled values for the builder 123 * @return builder 124 */ 125 public static CustomFieldsBuilder of(final CustomFields template) { 126 CustomFieldsBuilder builder = new CustomFieldsBuilder(); 127 builder.type = template.getType(); 128 builder.fields = template.getFields(); 129 return builder; 130 } 131 132}