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

com.urbanairship.api.channel.model.ChannelUninstallPayload Maven / Gradle / Ivy

There is a newer version: 9.3.0
Show newest version
package com.urbanairship.api.channel.model;

import java.util.Set;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;

/**
 * Represents a Channel Uninstall payload for the Airship API.
 */
public class ChannelUninstallPayload extends ChannelModelObject {

    private final Set channels;
    
    private ChannelUninstallPayload(Set channels) {
        this.channels = channels;
    }

    /**
     * ChannelUninstallPayload Builder
     *
     * @return Builder
     */
    public static Builder newBuilder() {
        return new Builder();
    }

    /**
     * Get the list of channels to uninstall.
     *
     * @return Set of ChannelUninstallDevice
     */
    public Set getChannels() {
        return channels;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ChannelUninstallPayload that = (ChannelUninstallPayload) o;
        return Objects.equal(channels, that.channels);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(channels);
    }

    @Override
    public String toString() {
        return "ChannelUninstallDevice{" +
                "channels=" + channels +
                '}';
    }

    public static class Builder {
        ImmutableSet.Builder channelsBuilder = ImmutableSet.builder();

        /**
         * Set the Set of ChannelUninstallDevice.
         *
         * @param channels Set of ChannelUninstallDevice
         * @return Builder
         */
        public Builder setChannels(Set channels) {
            channelsBuilder.addAll(channels);
            return this;
        }

        public ChannelUninstallPayload build() {
            ImmutableSet channels = channelsBuilder.build();

            Preconditions.checkArgument(channels.size() > 0, "At least one channel must be set.");
            Preconditions.checkArgument(channels.size() <= 1000, "Maximum of 1000 channels per payload.");

            return new ChannelUninstallPayload(channels);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy