001 002package com.commercetools.api.models.state; 003 004import java.util.*; 005import java.util.function.Function; 006 007import javax.annotation.Nullable; 008 009import io.vrap.rmf.base.client.Builder; 010import io.vrap.rmf.base.client.utils.Generated; 011 012/** 013 * StateSetTransitionsActionBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * StateSetTransitionsAction stateSetTransitionsAction = StateSetTransitionsAction.builder() 019 * .build() 020 * </code></pre> 021 * </div> 022 */ 023@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 024public class StateSetTransitionsActionBuilder implements Builder<StateSetTransitionsAction> { 025 026 @Nullable 027 private java.util.List<com.commercetools.api.models.state.StateResourceIdentifier> transitions; 028 029 /** 030 * <p>Value to set. If empty, any existing value will be removed.</p> 031 * <p>Possible transformations of the current State to other States of the same <code>type</code> (for example, <em>Initial</em> -> <em>Shipped</em>). When performing a <code>transitionState</code> update action and <code>transitions</code> is set, the currently referenced State must have a transition to the new State.</p> 032 * <p>If <code>transitions</code> is an empty list, it means the current State is a final State and no further transitions are allowed. If <code>transitions</code> is not set, the validation is turned off.</p> 033 * <p>When performing a <code>transitionState</code> update action, any other State of the same <code>type</code> can be transitioned to.</p> 034 * @param transitions value to be set 035 * @return Builder 036 */ 037 038 public StateSetTransitionsActionBuilder transitions( 039 @Nullable final com.commercetools.api.models.state.StateResourceIdentifier... transitions) { 040 this.transitions = new ArrayList<>(Arrays.asList(transitions)); 041 return this; 042 } 043 044 /** 045 * <p>Value to set. If empty, any existing value will be removed.</p> 046 * <p>Possible transformations of the current State to other States of the same <code>type</code> (for example, <em>Initial</em> -> <em>Shipped</em>). When performing a <code>transitionState</code> update action and <code>transitions</code> is set, the currently referenced State must have a transition to the new State.</p> 047 * <p>If <code>transitions</code> is an empty list, it means the current State is a final State and no further transitions are allowed. If <code>transitions</code> is not set, the validation is turned off.</p> 048 * <p>When performing a <code>transitionState</code> update action, any other State of the same <code>type</code> can be transitioned to.</p> 049 * @param transitions value to be set 050 * @return Builder 051 */ 052 053 public StateSetTransitionsActionBuilder transitions( 054 @Nullable final java.util.List<com.commercetools.api.models.state.StateResourceIdentifier> transitions) { 055 this.transitions = transitions; 056 return this; 057 } 058 059 /** 060 * <p>Value to set. If empty, any existing value will be removed.</p> 061 * <p>Possible transformations of the current State to other States of the same <code>type</code> (for example, <em>Initial</em> -> <em>Shipped</em>). When performing a <code>transitionState</code> update action and <code>transitions</code> is set, the currently referenced State must have a transition to the new State.</p> 062 * <p>If <code>transitions</code> is an empty list, it means the current State is a final State and no further transitions are allowed. If <code>transitions</code> is not set, the validation is turned off.</p> 063 * <p>When performing a <code>transitionState</code> update action, any other State of the same <code>type</code> can be transitioned to.</p> 064 * @param transitions value to be set 065 * @return Builder 066 */ 067 068 public StateSetTransitionsActionBuilder plusTransitions( 069 @Nullable final com.commercetools.api.models.state.StateResourceIdentifier... transitions) { 070 if (this.transitions == null) { 071 this.transitions = new ArrayList<>(); 072 } 073 this.transitions.addAll(Arrays.asList(transitions)); 074 return this; 075 } 076 077 /** 078 * <p>Value to set. If empty, any existing value will be removed.</p> 079 * <p>Possible transformations of the current State to other States of the same <code>type</code> (for example, <em>Initial</em> -> <em>Shipped</em>). When performing a <code>transitionState</code> update action and <code>transitions</code> is set, the currently referenced State must have a transition to the new State.</p> 080 * <p>If <code>transitions</code> is an empty list, it means the current State is a final State and no further transitions are allowed. If <code>transitions</code> is not set, the validation is turned off.</p> 081 * <p>When performing a <code>transitionState</code> update action, any other State of the same <code>type</code> can be transitioned to.</p> 082 * @param builder function to build the transitions value 083 * @return Builder 084 */ 085 086 public StateSetTransitionsActionBuilder plusTransitions( 087 Function<com.commercetools.api.models.state.StateResourceIdentifierBuilder, com.commercetools.api.models.state.StateResourceIdentifierBuilder> builder) { 088 if (this.transitions == null) { 089 this.transitions = new ArrayList<>(); 090 } 091 this.transitions 092 .add(builder.apply(com.commercetools.api.models.state.StateResourceIdentifierBuilder.of()).build()); 093 return this; 094 } 095 096 /** 097 * <p>Value to set. If empty, any existing value will be removed.</p> 098 * <p>Possible transformations of the current State to other States of the same <code>type</code> (for example, <em>Initial</em> -> <em>Shipped</em>). When performing a <code>transitionState</code> update action and <code>transitions</code> is set, the currently referenced State must have a transition to the new State.</p> 099 * <p>If <code>transitions</code> is an empty list, it means the current State is a final State and no further transitions are allowed. If <code>transitions</code> is not set, the validation is turned off.</p> 100 * <p>When performing a <code>transitionState</code> update action, any other State of the same <code>type</code> can be transitioned to.</p> 101 * @param builder function to build the transitions value 102 * @return Builder 103 */ 104 105 public StateSetTransitionsActionBuilder withTransitions( 106 Function<com.commercetools.api.models.state.StateResourceIdentifierBuilder, com.commercetools.api.models.state.StateResourceIdentifierBuilder> builder) { 107 this.transitions = new ArrayList<>(); 108 this.transitions 109 .add(builder.apply(com.commercetools.api.models.state.StateResourceIdentifierBuilder.of()).build()); 110 return this; 111 } 112 113 /** 114 * <p>Value to set. If empty, any existing value will be removed.</p> 115 * <p>Possible transformations of the current State to other States of the same <code>type</code> (for example, <em>Initial</em> -> <em>Shipped</em>). When performing a <code>transitionState</code> update action and <code>transitions</code> is set, the currently referenced State must have a transition to the new State.</p> 116 * <p>If <code>transitions</code> is an empty list, it means the current State is a final State and no further transitions are allowed. If <code>transitions</code> is not set, the validation is turned off.</p> 117 * <p>When performing a <code>transitionState</code> update action, any other State of the same <code>type</code> can be transitioned to.</p> 118 * @param builder function to build the transitions value 119 * @return Builder 120 */ 121 122 public StateSetTransitionsActionBuilder addTransitions( 123 Function<com.commercetools.api.models.state.StateResourceIdentifierBuilder, com.commercetools.api.models.state.StateResourceIdentifier> builder) { 124 return plusTransitions(builder.apply(com.commercetools.api.models.state.StateResourceIdentifierBuilder.of())); 125 } 126 127 /** 128 * <p>Value to set. If empty, any existing value will be removed.</p> 129 * <p>Possible transformations of the current State to other States of the same <code>type</code> (for example, <em>Initial</em> -> <em>Shipped</em>). When performing a <code>transitionState</code> update action and <code>transitions</code> is set, the currently referenced State must have a transition to the new State.</p> 130 * <p>If <code>transitions</code> is an empty list, it means the current State is a final State and no further transitions are allowed. If <code>transitions</code> is not set, the validation is turned off.</p> 131 * <p>When performing a <code>transitionState</code> update action, any other State of the same <code>type</code> can be transitioned to.</p> 132 * @param builder function to build the transitions value 133 * @return Builder 134 */ 135 136 public StateSetTransitionsActionBuilder setTransitions( 137 Function<com.commercetools.api.models.state.StateResourceIdentifierBuilder, com.commercetools.api.models.state.StateResourceIdentifier> builder) { 138 return transitions(builder.apply(com.commercetools.api.models.state.StateResourceIdentifierBuilder.of())); 139 } 140 141 /** 142 * <p>Value to set. If empty, any existing value will be removed.</p> 143 * <p>Possible transformations of the current State to other States of the same <code>type</code> (for example, <em>Initial</em> -> <em>Shipped</em>). When performing a <code>transitionState</code> update action and <code>transitions</code> is set, the currently referenced State must have a transition to the new State.</p> 144 * <p>If <code>transitions</code> is an empty list, it means the current State is a final State and no further transitions are allowed. If <code>transitions</code> is not set, the validation is turned off.</p> 145 * <p>When performing a <code>transitionState</code> update action, any other State of the same <code>type</code> can be transitioned to.</p> 146 * @return transitions 147 */ 148 149 @Nullable 150 public java.util.List<com.commercetools.api.models.state.StateResourceIdentifier> getTransitions() { 151 return this.transitions; 152 } 153 154 /** 155 * builds StateSetTransitionsAction with checking for non-null required values 156 * @return StateSetTransitionsAction 157 */ 158 public StateSetTransitionsAction build() { 159 return new StateSetTransitionsActionImpl(transitions); 160 } 161 162 /** 163 * builds StateSetTransitionsAction without checking for non-null required values 164 * @return StateSetTransitionsAction 165 */ 166 public StateSetTransitionsAction buildUnchecked() { 167 return new StateSetTransitionsActionImpl(transitions); 168 } 169 170 /** 171 * factory method for an instance of StateSetTransitionsActionBuilder 172 * @return builder 173 */ 174 public static StateSetTransitionsActionBuilder of() { 175 return new StateSetTransitionsActionBuilder(); 176 } 177 178 /** 179 * create builder for StateSetTransitionsAction instance 180 * @param template instance with prefilled values for the builder 181 * @return builder 182 */ 183 public static StateSetTransitionsActionBuilder of(final StateSetTransitionsAction template) { 184 StateSetTransitionsActionBuilder builder = new StateSetTransitionsActionBuilder(); 185 builder.transitions = template.getTransitions(); 186 return builder; 187 } 188 189}