io.sphere.sdk.subscriptions.SubscriptionDraftBuilder Maven / Gradle / Ivy
package io.sphere.sdk.subscriptions;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.utils.SphereInternalUtils;
import java.lang.String;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import javax.annotation.Nullable;
/**
* Builder for {@link SubscriptionDraft}.
*/
@Generated(
value = "io.sphere.sdk.annotations.processors.generators.DraftBuilderGenerator",
comments = "Generated from: io.sphere.sdk.subscriptions.SubscriptionDraft"
)
public final class SubscriptionDraftBuilder extends Base implements Builder {
@Nullable
private List changes;
private Destination destination;
@Nullable
private String key;
@Nullable
private List messages;
SubscriptionDraftBuilder() {
}
SubscriptionDraftBuilder(@Nullable final List changes,
final Destination destination, @Nullable final String key,
@Nullable final List messages) {
this.changes = changes;
this.destination = destination;
this.key = key;
this.messages = messages;
}
/**
* Sets the {@code changes} property of this builder.
*
* @param changes the value for {@link SubscriptionDraft#getChanges()}
* @return this builder
*/
public SubscriptionDraftBuilder changes(@Nullable final List changes) {
this.changes = changes;
return this;
}
/**
* Sets the {@code destination} property of this builder.
*
* @param destination the value for {@link SubscriptionDraft#getDestination()}
* @return this builder
*/
public SubscriptionDraftBuilder destination(final Destination destination) {
this.destination = destination;
return this;
}
/**
* Sets the {@code key} property of this builder.
*
* @param key the value for {@link SubscriptionDraft#getKey()}
* @return this builder
*/
public SubscriptionDraftBuilder key(@Nullable final String key) {
this.key = key;
return this;
}
/**
* Sets the {@code messages} property of this builder.
*
* @param messages the value for {@link SubscriptionDraft#getMessages()}
* @return this builder
*/
public SubscriptionDraftBuilder messages(@Nullable final List messages) {
this.messages = messages;
return this;
}
@Nullable
public List getChanges() {
return changes;
}
public Destination getDestination() {
return destination;
}
@Nullable
public String getKey() {
return key;
}
@Nullable
public List getMessages() {
return messages;
}
/**
* Concatenate {@code changes} parameter to the {@code changes} list property of this builder.
*
* @param changes the value for {@link SubscriptionDraft#getChanges()}
* @return this builder
*/
public SubscriptionDraftBuilder plusChanges(final List changes) {
this.changes = SphereInternalUtils.listOf(Optional.ofNullable(this.changes).orElseGet(ArrayList::new), changes);
return this;
}
/**
* Concatenate {@code messages} parameter to the {@code messages} list property of this builder.
*
* @param messages the value for {@link SubscriptionDraft#getMessages()}
* @return this builder
*/
public SubscriptionDraftBuilder plusMessages(final List messages) {
this.messages = SphereInternalUtils.listOf(Optional.ofNullable(this.messages).orElseGet(ArrayList::new), messages);
return this;
}
/**
* Adds {@code changes} parameter to the {@code changes} list property of this builder.
*
* @param changes the value of the element to add to {@link SubscriptionDraft#getChanges()}
* @return this builder
*/
public SubscriptionDraftBuilder plusChanges(final ChangeSubscription changes) {
this.changes = SphereInternalUtils.listOf(Optional.ofNullable(this.changes).orElseGet(ArrayList::new), Collections.singletonList(changes));
return this;
}
/**
* Adds {@code messages} parameter to the {@code messages} list property of this builder.
*
* @param messages the value of the element to add to {@link SubscriptionDraft#getMessages()}
* @return this builder
*/
public SubscriptionDraftBuilder plusMessages(final MessageSubscription messages) {
this.messages = SphereInternalUtils.listOf(Optional.ofNullable(this.messages).orElseGet(ArrayList::new), Collections.singletonList(messages));
return this;
}
/**
* Creates a new instance of {@code SubscriptionDraftDsl} with the values of this builder.
*
* @return the instance
*/
public SubscriptionDraftDsl build() {
return new SubscriptionDraftDsl(changes, destination, key, messages);
}
/**
* Creates a new object initialized with the given values.
*
* @param destination initial value for the {@link SubscriptionDraft#getDestination()} property
* @return new object initialized with the given values
*/
public static SubscriptionDraftBuilder of(final Destination destination) {
return new SubscriptionDraftBuilder(null, destination, null, null);
}
/**
* Creates a new object initialized with the fields of the template parameter.
*
* @param template the template
* @return a new object initialized from the template
*/
public static SubscriptionDraftBuilder of(final SubscriptionDraft template) {
return new SubscriptionDraftBuilder(template.getChanges(), template.getDestination(), template.getKey(), template.getMessages());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy