All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.channels.ChannelDraft Maven / Gradle / Ivy

There is a newer version: 1.0.0-M12
Show newest version
package io.sphere.sdk.channels;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.LocalizedStrings;

import java.util.Collections;
import java.util.Optional;
import java.util.Set;

import static io.sphere.sdk.utils.SetUtils.asSet;

/**
 * Template to create a new Channel.
 *
 * @see ChannelDraftBuilder
 */
public class ChannelDraft extends Base {
    private final String key;
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private final Set roles;
    private final Optional name;
    private final Optional description;

    ChannelDraft(final String key, final Set roles, final Optional name, final Optional description) {
        this.key = key;
        this.roles = roles;
        this.name = name;
        this.description = description;
    }

    public static ChannelDraft of(final String key) {
        return new ChannelDraft(key, Collections.emptySet(), Optional.empty(), Optional.empty());
    }

    public String getKey() {
        return key;
    }

    public Set getRoles() {
        return roles;
    }

    public Optional getName() {
        return name;
    }

    public Optional getDescription() {
        return description;
    }
    
    public ChannelDraft withRoles(final Set roles) {
        return ChannelDraftBuilder.of(this).roles(roles).build();
    }

    public ChannelDraft withRoles(final ChannelRoles ... roles) {
        return ChannelDraftBuilder.of(this).roles(asSet(roles)).build();
    }
    
    public ChannelDraft withName(final Optional name) {
        return ChannelDraftBuilder.of(this).name(name).build();
    }  
    
    public ChannelDraft withName(final LocalizedStrings name) {
        return withName(Optional.of(name));
    }    
    
    public ChannelDraft withDescription(final Optional description) {
        return ChannelDraftBuilder.of(this).description(description).build();
    }  
    
    public ChannelDraft withDescription(final LocalizedStrings description) {
        return withDescription(Optional.of(description));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy