001 002package com.commercetools.api.models.common; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007import java.util.stream.Collectors; 008 009import javax.annotation.Nullable; 010import javax.validation.Valid; 011import javax.validation.constraints.NotNull; 012 013import com.commercetools.api.models.type.CustomFields; 014import com.fasterxml.jackson.annotation.*; 015import com.fasterxml.jackson.databind.annotation.*; 016 017import io.vrap.rmf.base.client.utils.Generated; 018 019/** 020 * Asset 021 * 022 * <hr> 023 * Example to create an instance using the builder pattern 024 * <div class=code-example> 025 * <pre><code class='java'> 026 * Asset asset = Asset.builder() 027 * .id("{id}") 028 * .plusSources(sourcesBuilder -> sourcesBuilder) 029 * .name(nameBuilder -> nameBuilder) 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 = AssetImpl.class) 036public interface Asset extends com.commercetools.api.models.Customizable<Asset>, com.commercetools.api.models.WithKey { 037 038 /** 039 * <p>Unique identifier of the Asset.</p> 040 * @return id 041 */ 042 @NotNull 043 @JsonProperty("id") 044 public String getId(); 045 046 /** 047 * 048 * @return sources 049 */ 050 @NotNull 051 @Valid 052 @JsonProperty("sources") 053 public List<AssetSource> getSources(); 054 055 /** 056 * <p>Name of the Asset.</p> 057 * @return name 058 */ 059 @NotNull 060 @Valid 061 @JsonProperty("name") 062 public LocalizedString getName(); 063 064 /** 065 * <p>Description of the Asset.</p> 066 * @return description 067 */ 068 @Valid 069 @JsonProperty("description") 070 public LocalizedString getDescription(); 071 072 /** 073 * <p>Keywords for categorizing and organizing Assets.</p> 074 * @return tags 075 */ 076 077 @JsonProperty("tags") 078 public List<String> getTags(); 079 080 /** 081 * <p>Custom Fields defined for the Asset.</p> 082 * @return custom 083 */ 084 @Valid 085 @JsonProperty("custom") 086 public CustomFields getCustom(); 087 088 /** 089 * <p>User-defined unique identifier of the Asset.</p> 090 * @return key 091 */ 092 093 @JsonProperty("key") 094 public String getKey(); 095 096 /** 097 * <p>Unique identifier of the Asset.</p> 098 * @param id value to be set 099 */ 100 101 public void setId(final String id); 102 103 /** 104 * set sources 105 * @param sources values to be set 106 */ 107 108 @JsonIgnore 109 public void setSources(final AssetSource... sources); 110 111 /** 112 * set sources 113 * @param sources values to be set 114 */ 115 116 public void setSources(final List<AssetSource> sources); 117 118 /** 119 * <p>Name of the Asset.</p> 120 * @param name value to be set 121 */ 122 123 public void setName(final LocalizedString name); 124 125 /** 126 * <p>Description of the Asset.</p> 127 * @param description value to be set 128 */ 129 130 public void setDescription(final LocalizedString description); 131 132 /** 133 * <p>Keywords for categorizing and organizing Assets.</p> 134 * @param tags values to be set 135 */ 136 137 @JsonIgnore 138 public void setTags(final String... tags); 139 140 /** 141 * <p>Keywords for categorizing and organizing Assets.</p> 142 * @param tags values to be set 143 */ 144 145 public void setTags(final List<String> tags); 146 147 /** 148 * <p>Custom Fields defined for the Asset.</p> 149 * @param custom value to be set 150 */ 151 152 public void setCustom(final CustomFields custom); 153 154 /** 155 * <p>User-defined unique identifier of the Asset.</p> 156 * @param key value to be set 157 */ 158 159 public void setKey(final String key); 160 161 /** 162 * factory method 163 * @return instance of Asset 164 */ 165 public static Asset of() { 166 return new AssetImpl(); 167 } 168 169 /** 170 * factory method to create a shallow copy Asset 171 * @param template instance to be copied 172 * @return copy instance 173 */ 174 public static Asset of(final Asset template) { 175 AssetImpl instance = new AssetImpl(); 176 instance.setId(template.getId()); 177 instance.setSources(template.getSources()); 178 instance.setName(template.getName()); 179 instance.setDescription(template.getDescription()); 180 instance.setTags(template.getTags()); 181 instance.setCustom(template.getCustom()); 182 instance.setKey(template.getKey()); 183 return instance; 184 } 185 186 /** 187 * factory method to create a deep copy of Asset 188 * @param template instance to be copied 189 * @return copy instance 190 */ 191 @Nullable 192 public static Asset deepCopy(@Nullable final Asset template) { 193 if (template == null) { 194 return null; 195 } 196 AssetImpl instance = new AssetImpl(); 197 instance.setId(template.getId()); 198 instance.setSources(Optional.ofNullable(template.getSources()) 199 .map(t -> t.stream() 200 .map(com.commercetools.api.models.common.AssetSource::deepCopy) 201 .collect(Collectors.toList())) 202 .orElse(null)); 203 instance.setName(com.commercetools.api.models.common.LocalizedString.deepCopy(template.getName())); 204 instance.setDescription( 205 com.commercetools.api.models.common.LocalizedString.deepCopy(template.getDescription())); 206 instance.setTags(Optional.ofNullable(template.getTags()).map(ArrayList::new).orElse(null)); 207 instance.setCustom(com.commercetools.api.models.type.CustomFields.deepCopy(template.getCustom())); 208 instance.setKey(template.getKey()); 209 return instance; 210 } 211 212 /** 213 * builder factory method for Asset 214 * @return builder 215 */ 216 public static AssetBuilder builder() { 217 return AssetBuilder.of(); 218 } 219 220 /** 221 * create builder for Asset instance 222 * @param template instance with prefilled values for the builder 223 * @return builder 224 */ 225 public static AssetBuilder builder(final Asset template) { 226 return AssetBuilder.of(template); 227 } 228 229 /** 230 * accessor map function 231 * @param <T> mapped type 232 * @param helper function to map the object 233 * @return mapped value 234 */ 235 default <T> T withAsset(Function<Asset, T> helper) { 236 return helper.apply(this); 237 } 238 239 /** 240 * gives a TypeReference for usage with Jackson DataBind 241 * @return TypeReference 242 */ 243 public static com.fasterxml.jackson.core.type.TypeReference<Asset> typeReference() { 244 return new com.fasterxml.jackson.core.type.TypeReference<Asset>() { 245 @Override 246 public String toString() { 247 return "TypeReference<Asset>"; 248 } 249 }; 250 } 251}