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

com.urbanairship.api.nameduser.model.NamedUserUpdateChannel Maven / Gradle / Ivy

There is a newer version: 9.4.2
Show newest version
package com.urbanairship.api.nameduser.model;

import com.google.common.base.Preconditions;

import java.util.Optional;

/**
 * Object that represents individual NamedUserUpdateChannel.
 */
public class NamedUserUpdateChannel {
    private final Optional deviceType;
    private final Optional channelId;
    private final Optional emailAddress;


    private NamedUserUpdateChannel(Builder builder) {
        this.deviceType = Optional.ofNullable(builder.deviceType);
        this.channelId = Optional.ofNullable(builder.channelId);
        this.emailAddress = Optional.ofNullable(builder.emailAddress);

    }

    /**
     * New NamedUserUpdateChannel builder.
     *
     * @return Builder
     */
    public static Builder newBuilder() {
        return new Builder();
    }

    /**
     * Get the NamedUserUpdateChannel device type.
     *
     * @return String deviceType
     */
    public Optional getDeviceType() {
        return deviceType;
    }

    /**
     * Get the NamedUserUpdateChannel channelId.
     *
     * @return String channelId
     */
    public Optional getChannelId() {
        return channelId;
    }

    /**
     * Get the NamedUserUpdateChannel emailAddress.
     *
     * @return String emaimAddress
     */
    public Optional getEmailAddress() {
        return emailAddress;
    }


    /**
     * Create NamedUserUpdateChannel Builder
     */
    public static class Builder {
        NamedUserUpdateDeviceType deviceType;
        String channelId;
        String emailAddress;

        /**
         * Indicates that add a channel.
         *
         * @param deviceType String
         * @param channelId String
         * @return Builder
         */
        public Builder addChannel(NamedUserUpdateDeviceType deviceType, String channelId) {
            this.deviceType = deviceType;
            this.channelId = channelId;
            return this;
        }

        /**
         * Indicates that add an email address.
         *
         * @param emailAddress String
         * @return Builder
         */
        public Builder addEmailAddress(String emailAddress) {
            this.emailAddress = emailAddress;
            return this;
        }

        public NamedUserUpdateChannel build() {
            Preconditions.checkArgument(channelId != null ^ emailAddress != null, "You can only add channel OR an email address");

            return new NamedUserUpdateChannel(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy