001 002package com.commercetools.importapi.models.customfields; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007 008import javax.annotation.Nullable; 009import javax.validation.Valid; 010import javax.validation.constraints.NotNull; 011 012import com.fasterxml.jackson.annotation.*; 013import com.fasterxml.jackson.databind.annotation.*; 014 015import io.vrap.rmf.base.client.utils.Generated; 016 017/** 018 * <p>Maps the custom field names to the actual values.</p> 019 * 020 * <hr> 021 * Example to create an instance using the builder pattern 022 * <div class=code-example> 023 * <pre><code class='java'> 024 * FieldContainer fieldContainer = FieldContainer.builder() 025 * .//(//Builder -> //Builder) 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 = FieldContainerImpl.class) 032public interface FieldContainer { 033 034 /** 035 * <p>Mapping from the custom field name to the actual value.</p> 036 * @return map of the pattern property values 037 */ 038 @NotNull 039 @Valid 040 @JsonAnyGetter 041 public Map<String, CustomField> values(); 042 043 /** 044 * <p>Mapping from the custom field name to the actual value.</p> 045 * @param key property name 046 * @param value property value 047 */ 048 049 @JsonAnySetter 050 public void setValue(String key, CustomField value); 051 052 /** 053 * factory method 054 * @return instance of FieldContainer 055 */ 056 public static FieldContainer of() { 057 return new FieldContainerImpl(); 058 } 059 060 /** 061 * factory method to create a shallow copy FieldContainer 062 * @param template instance to be copied 063 * @return copy instance 064 */ 065 public static FieldContainer of(final FieldContainer template) { 066 FieldContainerImpl instance = new FieldContainerImpl(); 067 Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue)); 068 return instance; 069 } 070 071 /** 072 * factory method to create a deep copy of FieldContainer 073 * @param template instance to be copied 074 * @return copy instance 075 */ 076 @Nullable 077 public static FieldContainer deepCopy(@Nullable final FieldContainer template) { 078 if (template == null) { 079 return null; 080 } 081 FieldContainerImpl instance = new FieldContainerImpl(); 082 Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue)); 083 return instance; 084 } 085 086 /** 087 * builder factory method for FieldContainer 088 * @return builder 089 */ 090 public static FieldContainerBuilder builder() { 091 return FieldContainerBuilder.of(); 092 } 093 094 /** 095 * create builder for FieldContainer instance 096 * @param template instance with prefilled values for the builder 097 * @return builder 098 */ 099 public static FieldContainerBuilder builder(final FieldContainer template) { 100 return FieldContainerBuilder.of(template); 101 } 102 103 /** 104 * accessor map function 105 * @param <T> mapped type 106 * @param helper function to map the object 107 * @return mapped value 108 */ 109 default <T> T withFieldContainer(Function<FieldContainer, T> helper) { 110 return helper.apply(this); 111 } 112 113 /** 114 * gives a TypeReference for usage with Jackson DataBind 115 * @return TypeReference 116 */ 117 public static com.fasterxml.jackson.core.type.TypeReference<FieldContainer> typeReference() { 118 return new com.fasterxml.jackson.core.type.TypeReference<FieldContainer>() { 119 @Override 120 public String toString() { 121 return "TypeReference<FieldContainer>"; 122 } 123 }; 124 } 125}