001 002package com.commercetools.api.models.business_unit; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007import java.util.stream.Collectors; 008 009import javax.annotation.Nullable; 010 011import com.fasterxml.jackson.annotation.*; 012import com.fasterxml.jackson.databind.annotation.*; 013 014import io.vrap.rmf.base.client.utils.Generated; 015 016/** 017 * <p>Draft type to represent the top level of a business. Contains the fields and values of the generic BusinessUnitDraft that are used specifically for creating a Company.</p> 018 * 019 * <hr> 020 * Example to create an instance using the builder pattern 021 * <div class=code-example> 022 * <pre><code class='java'> 023 * CompanyDraft companyDraft = CompanyDraft.builder() 024 * .key("{key}") 025 * .name("{name}") 026 * .build() 027 * </code></pre> 028 * </div> 029 */ 030@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 031@JsonDeserialize(as = CompanyDraftImpl.class) 032public interface CompanyDraft extends BusinessUnitDraft, io.vrap.rmf.base.client.Draft<CompanyDraft> { 033 034 /** 035 * discriminator value for CompanyDraft 036 */ 037 String COMPANY = "Company"; 038 039 /** 040 * factory method 041 * @return instance of CompanyDraft 042 */ 043 public static CompanyDraft of() { 044 return new CompanyDraftImpl(); 045 } 046 047 /** 048 * factory method to create a shallow copy CompanyDraft 049 * @param template instance to be copied 050 * @return copy instance 051 */ 052 public static CompanyDraft of(final CompanyDraft template) { 053 CompanyDraftImpl instance = new CompanyDraftImpl(); 054 instance.setKey(template.getKey()); 055 instance.setStatus(template.getStatus()); 056 instance.setStores(template.getStores()); 057 instance.setStoreMode(template.getStoreMode()); 058 instance.setName(template.getName()); 059 instance.setContactEmail(template.getContactEmail()); 060 instance.setAssociateMode(template.getAssociateMode()); 061 instance.setAssociates(template.getAssociates()); 062 instance.setAddresses(template.getAddresses()); 063 instance.setShippingAddresses(template.getShippingAddresses()); 064 instance.setDefaultShippingAddress(template.getDefaultShippingAddress()); 065 instance.setBillingAddresses(template.getBillingAddresses()); 066 instance.setDefaultBillingAddress(template.getDefaultBillingAddress()); 067 instance.setCustom(template.getCustom()); 068 return instance; 069 } 070 071 /** 072 * factory method to create a deep copy of CompanyDraft 073 * @param template instance to be copied 074 * @return copy instance 075 */ 076 @Nullable 077 public static CompanyDraft deepCopy(@Nullable final CompanyDraft template) { 078 if (template == null) { 079 return null; 080 } 081 CompanyDraftImpl instance = new CompanyDraftImpl(); 082 instance.setKey(template.getKey()); 083 instance.setStatus(template.getStatus()); 084 instance.setStores(Optional.ofNullable(template.getStores()) 085 .map(t -> t.stream() 086 .map(com.commercetools.api.models.store.StoreResourceIdentifier::deepCopy) 087 .collect(Collectors.toList())) 088 .orElse(null)); 089 instance.setStoreMode(template.getStoreMode()); 090 instance.setName(template.getName()); 091 instance.setContactEmail(template.getContactEmail()); 092 instance.setAssociateMode(template.getAssociateMode()); 093 instance.setAssociates(Optional.ofNullable(template.getAssociates()) 094 .map(t -> t.stream() 095 .map(com.commercetools.api.models.business_unit.AssociateDraft::deepCopy) 096 .collect(Collectors.toList())) 097 .orElse(null)); 098 instance.setAddresses(Optional.ofNullable(template.getAddresses()) 099 .map(t -> t.stream() 100 .map(com.commercetools.api.models.common.BaseAddress::deepCopy) 101 .collect(Collectors.toList())) 102 .orElse(null)); 103 instance.setShippingAddresses( 104 Optional.ofNullable(template.getShippingAddresses()).map(ArrayList::new).orElse(null)); 105 instance.setDefaultShippingAddress(template.getDefaultShippingAddress()); 106 instance.setBillingAddresses( 107 Optional.ofNullable(template.getBillingAddresses()).map(ArrayList::new).orElse(null)); 108 instance.setDefaultBillingAddress(template.getDefaultBillingAddress()); 109 instance.setCustom(com.commercetools.api.models.type.CustomFieldsDraft.deepCopy(template.getCustom())); 110 return instance; 111 } 112 113 /** 114 * builder factory method for CompanyDraft 115 * @return builder 116 */ 117 public static CompanyDraftBuilder builder() { 118 return CompanyDraftBuilder.of(); 119 } 120 121 /** 122 * create builder for CompanyDraft instance 123 * @param template instance with prefilled values for the builder 124 * @return builder 125 */ 126 public static CompanyDraftBuilder builder(final CompanyDraft template) { 127 return CompanyDraftBuilder.of(template); 128 } 129 130 /** 131 * accessor map function 132 * @param <T> mapped type 133 * @param helper function to map the object 134 * @return mapped value 135 */ 136 default <T> T withCompanyDraft(Function<CompanyDraft, T> helper) { 137 return helper.apply(this); 138 } 139 140 /** 141 * gives a TypeReference for usage with Jackson DataBind 142 * @return TypeReference 143 */ 144 public static com.fasterxml.jackson.core.type.TypeReference<CompanyDraft> typeReference() { 145 return new com.fasterxml.jackson.core.type.TypeReference<CompanyDraft>() { 146 @Override 147 public String toString() { 148 return "TypeReference<CompanyDraft>"; 149 } 150 }; 151 } 152}