001 002package com.commercetools.importapi.models.common; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007 008import javax.annotation.Nullable; 009import javax.validation.constraints.NotNull; 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>A localized string is a JSON object where the keys are of IETF language tag, and the values the corresponding strings used for that language.</p> 018 * <pre><code>{ 019 * "de": "Hundefutter", 020 * "en": "dog food" 021 * } 022 * </code></pre> 023 * 024 * <hr> 025 * Example to create an instance using the builder pattern 026 * <div class=code-example> 027 * <pre><code class='java'> 028 * LocalizedString localizedString = LocalizedString.builder() 029 * ./^[a-z]{2}(-[A-Z]{2})?$/("{/^[a-z]{2}(-[A-Z]{2})?$/}") 030 * .build() 031 * </code></pre> 032 * </div> 033 */ 034@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 035@JsonDeserialize(as = LocalizedStringImpl.class) 036public interface LocalizedString { 037 038 /** 039 * 040 * @return map of the pattern property values 041 */ 042 @NotNull 043 @JsonAnyGetter 044 public Map<String, String> values(); 045 046 /** 047 * set pattern property 048 * @param key property name 049 * @param value property value 050 */ 051 052 @JsonAnySetter 053 public void setValue(String key, String value); 054 055 /** 056 * factory method 057 * @return instance of LocalizedString 058 */ 059 public static LocalizedString of() { 060 return new LocalizedStringImpl(); 061 } 062 063 /** 064 * factory method to create a shallow copy LocalizedString 065 * @param template instance to be copied 066 * @return copy instance 067 */ 068 public static LocalizedString of(final LocalizedString template) { 069 LocalizedStringImpl instance = new LocalizedStringImpl(); 070 Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue)); 071 return instance; 072 } 073 074 /** 075 * factory method to create a deep copy of LocalizedString 076 * @param template instance to be copied 077 * @return copy instance 078 */ 079 @Nullable 080 public static LocalizedString deepCopy(@Nullable final LocalizedString template) { 081 if (template == null) { 082 return null; 083 } 084 LocalizedStringImpl instance = new LocalizedStringImpl(); 085 Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue)); 086 return instance; 087 } 088 089 /** 090 * builder factory method for LocalizedString 091 * @return builder 092 */ 093 public static LocalizedStringBuilder builder() { 094 return LocalizedStringBuilder.of(); 095 } 096 097 /** 098 * create builder for LocalizedString instance 099 * @param template instance with prefilled values for the builder 100 * @return builder 101 */ 102 public static LocalizedStringBuilder builder(final LocalizedString template) { 103 return LocalizedStringBuilder.of(template); 104 } 105 106 /** 107 * accessor map function 108 * @param <T> mapped type 109 * @param helper function to map the object 110 * @return mapped value 111 */ 112 default <T> T withLocalizedString(Function<LocalizedString, T> helper) { 113 return helper.apply(this); 114 } 115 116 /** 117 * gives a TypeReference for usage with Jackson DataBind 118 * @return TypeReference 119 */ 120 public static com.fasterxml.jackson.core.type.TypeReference<LocalizedString> typeReference() { 121 return new com.fasterxml.jackson.core.type.TypeReference<LocalizedString>() { 122 @Override 123 public String toString() { 124 return "TypeReference<LocalizedString>"; 125 } 126 }; 127 } 128}