io.sphere.sdk.channels.ChannelDraftBuilder Maven / Gradle / Ivy
package io.sphere.sdk.channels;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.models.LocalizedStrings;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
public class ChannelDraftBuilder extends Base implements Builder {
private final String key;
private Set roles = Collections.emptySet();
private Optional name = Optional.empty();
private Optional description = Optional.empty();
public ChannelDraftBuilder(final String key) {
this.key = key;
}
public static ChannelDraftBuilder of(final String key) {
return new ChannelDraftBuilder(key);
}
public static ChannelDraftBuilder of(final ChannelDraft template) {
return new ChannelDraftBuilder(template.getKey())
.roles(template.getRoles())
.name(template.getName())
.description(template.getDescription());
}
public ChannelDraftBuilder description(final Optional description) {
this.description = description;
return this;
}
public ChannelDraftBuilder description(final LocalizedStrings description) {
return description(Optional.ofNullable(description));
}
public ChannelDraftBuilder name(final Optional name) {
this.name = name;
return this;
}
public ChannelDraftBuilder name(final LocalizedStrings name) {
return name(Optional.ofNullable(name));
}
public ChannelDraftBuilder roles(final Set roles) {
this.roles = roles;
return this;
}
@Override
public ChannelDraft build() {
return new ChannelDraft(key, roles, name, description);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy