001 002package com.commercetools.api.models.channel; 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.fasterxml.jackson.annotation.*; 014import com.fasterxml.jackson.databind.annotation.*; 015 016import io.vrap.rmf.base.client.utils.Generated; 017 018/** 019 * ChannelUpdate 020 * 021 * <hr> 022 * Example to create an instance using the builder pattern 023 * <div class=code-example> 024 * <pre><code class='java'> 025 * ChannelUpdate channelUpdate = ChannelUpdate.builder() 026 * .version(0.3) 027 * .plusActions(actionsBuilder -> actionsBuilder) 028 * .build() 029 * </code></pre> 030 * </div> 031 */ 032@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 033@JsonDeserialize(as = ChannelUpdateImpl.class) 034public interface ChannelUpdate 035 extends com.commercetools.api.models.ResourceUpdate<ChannelUpdate, ChannelUpdateAction, ChannelUpdateBuilder> { 036 037 /** 038 * <p>Expected version of the Channel on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error is returned.</p> 039 * @return version 040 */ 041 @NotNull 042 @JsonProperty("version") 043 public Long getVersion(); 044 045 /** 046 * <p>Update actions to be performed on the Channel.</p> 047 * @return actions 048 */ 049 @NotNull 050 @Valid 051 @JsonProperty("actions") 052 public List<ChannelUpdateAction> getActions(); 053 054 /** 055 * <p>Expected version of the Channel on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error is returned.</p> 056 * @param version value to be set 057 */ 058 059 public void setVersion(final Long version); 060 061 /** 062 * <p>Update actions to be performed on the Channel.</p> 063 * @param actions values to be set 064 */ 065 066 @JsonIgnore 067 public void setActions(final ChannelUpdateAction... actions); 068 069 /** 070 * <p>Update actions to be performed on the Channel.</p> 071 * @param actions values to be set 072 */ 073 074 public void setActions(final List<ChannelUpdateAction> actions); 075 076 /** 077 * factory method 078 * @return instance of ChannelUpdate 079 */ 080 public static ChannelUpdate of() { 081 return new ChannelUpdateImpl(); 082 } 083 084 /** 085 * factory method to create a shallow copy ChannelUpdate 086 * @param template instance to be copied 087 * @return copy instance 088 */ 089 public static ChannelUpdate of(final ChannelUpdate template) { 090 ChannelUpdateImpl instance = new ChannelUpdateImpl(); 091 instance.setVersion(template.getVersion()); 092 instance.setActions(template.getActions()); 093 return instance; 094 } 095 096 /** 097 * factory method to create a deep copy of ChannelUpdate 098 * @param template instance to be copied 099 * @return copy instance 100 */ 101 @Nullable 102 public static ChannelUpdate deepCopy(@Nullable final ChannelUpdate template) { 103 if (template == null) { 104 return null; 105 } 106 ChannelUpdateImpl instance = new ChannelUpdateImpl(); 107 instance.setVersion(template.getVersion()); 108 instance.setActions(Optional.ofNullable(template.getActions()) 109 .map(t -> t.stream() 110 .map(com.commercetools.api.models.channel.ChannelUpdateAction::deepCopy) 111 .collect(Collectors.toList())) 112 .orElse(null)); 113 return instance; 114 } 115 116 /** 117 * builder factory method for ChannelUpdate 118 * @return builder 119 */ 120 public static ChannelUpdateBuilder builder() { 121 return ChannelUpdateBuilder.of(); 122 } 123 124 /** 125 * create builder for ChannelUpdate instance 126 * @param template instance with prefilled values for the builder 127 * @return builder 128 */ 129 public static ChannelUpdateBuilder builder(final ChannelUpdate template) { 130 return ChannelUpdateBuilder.of(template); 131 } 132 133 /** 134 * accessor map function 135 * @param <T> mapped type 136 * @param helper function to map the object 137 * @return mapped value 138 */ 139 default <T> T withChannelUpdate(Function<ChannelUpdate, T> helper) { 140 return helper.apply(this); 141 } 142 143 /** 144 * gives a TypeReference for usage with Jackson DataBind 145 * @return TypeReference 146 */ 147 public static com.fasterxml.jackson.core.type.TypeReference<ChannelUpdate> typeReference() { 148 return new com.fasterxml.jackson.core.type.TypeReference<ChannelUpdate>() { 149 @Override 150 public String toString() { 151 return "TypeReference<ChannelUpdate>"; 152 } 153 }; 154 } 155}