com.urbanairship.api.channel.model.subscriptionlist.SubscriptionListPayload Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-client Show documentation
Show all versions of java-client Show documentation
The Urban Airship Java client library
package com.urbanairship.api.channel.model.subscriptionlist;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.urbanairship.api.channel.model.ChannelAudience;
import com.urbanairship.api.channel.model.ChannelModelObject;
/**
* Represents a Channel Subscription List payload for the Airship API.
*/
public class SubscriptionListPayload extends ChannelModelObject {
private final ChannelAudience audience;
ImmutableList subscriptionList;
private SubscriptionListPayload(ChannelAudience audience, ImmutableList subscriptionList) {
this.audience = audience;
this.subscriptionList = subscriptionList;
}
/**
* SubscriptionListPayload Builder
*
* @return Builder
*/
public static Builder newBuilder() {
return new Builder();
}
/**
* Get the audience that determines the set of channels to target.
*
* @return ChannelAudience audience
*/
public ChannelAudience getAudience() {
return audience;
}
/**
* Get the Subscription list to subscribe or unsubscribe for the audience.
*
* @return ImmutableList of SubscriptionList subscriptionList
*/
public ImmutableList getSubscriptionList() {
return subscriptionList;
}
public static class Builder {
ChannelAudience audience;
ImmutableList.Builder subscriptionListBuilder = ImmutableList.builder();
/**
* Set the audience that determines the set of channels to target.
*
* @param audience ChannelAudience
* @return Builder
*/
public Builder setAudience(ChannelAudience audience) {
this.audience = audience;
return this;
}
/**
* Subscribe or unsubscribe a subscription list, for the audience.
*
* @param subscriptionList SubscriptionList
* @return Builder
*/
public Builder addSubscriptionList(SubscriptionList subscriptionList) {
subscriptionListBuilder.add(subscriptionList);
return this;
}
public SubscriptionListPayload build() {
ImmutableList subscriptionList = subscriptionListBuilder.build();
Preconditions.checkNotNull(audience, "Audience must be set.");
Preconditions.checkArgument(subscriptionList.size() > 0, "Subscription List must be added to SubscriptionListPayload.");
return new SubscriptionListPayload(audience, subscriptionList);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy