com.spotify.google.cloud.pubsub.client.SubscriptionListBuilder Maven / Gradle / Ivy
package com.spotify.google.cloud.pubsub.client;
import io.norberg.automatter.AutoMatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
@Generated("io.norberg.automatter.processor.AutoMatterProcessor")
public final class SubscriptionListBuilder {
private List subscriptions;
private Optional nextPageToken;
public SubscriptionListBuilder() {
this.nextPageToken = Optional.empty();
}
private SubscriptionListBuilder(SubscriptionList v) {
List extends Subscription> _subscriptions = v.subscriptions();
this.subscriptions = (_subscriptions == null) ? null : new ArrayList(_subscriptions);
this.nextPageToken = v.nextPageToken();
}
private SubscriptionListBuilder(SubscriptionListBuilder v) {
this.subscriptions = (v.subscriptions == null) ? null : new ArrayList(v.subscriptions);
this.nextPageToken = v.nextPageToken;
}
public List subscriptions() {
if (this.subscriptions == null) {
this.subscriptions = new ArrayList();
}
return subscriptions;
}
public SubscriptionListBuilder subscriptions(List extends Subscription> subscriptions) {
return subscriptions((Collection extends Subscription>) subscriptions);
}
public SubscriptionListBuilder subscriptions(Collection extends Subscription> subscriptions) {
if (subscriptions == null) {
throw new NullPointerException("subscriptions");
}
for (Subscription item : subscriptions) {
if (item == null) {
throw new NullPointerException("subscriptions: null item");
}
}
this.subscriptions = new ArrayList(subscriptions);
return this;
}
public SubscriptionListBuilder subscriptions(Iterable extends Subscription> subscriptions) {
if (subscriptions == null) {
throw new NullPointerException("subscriptions");
}
if (subscriptions instanceof Collection) {
return subscriptions((Collection extends Subscription>) subscriptions);
}
return subscriptions(subscriptions.iterator());
}
public SubscriptionListBuilder subscriptions(Iterator extends Subscription> subscriptions) {
if (subscriptions == null) {
throw new NullPointerException("subscriptions");
}
this.subscriptions = new ArrayList();
while (subscriptions.hasNext()) {
Subscription item = subscriptions.next();
if (item == null) {
throw new NullPointerException("subscriptions: null item");
}
this.subscriptions.add(item);
}
return this;
}
@SafeVarargs
public final SubscriptionListBuilder subscriptions(Subscription... subscriptions) {
if (subscriptions == null) {
throw new NullPointerException("subscriptions");
}
return subscriptions(Arrays.asList(subscriptions));
}
public SubscriptionListBuilder addSubscription(Subscription subscription) {
if (subscription == null) {
throw new NullPointerException("subscription");
}
if (this.subscriptions == null) {
this.subscriptions = new ArrayList();
}
subscriptions.add(subscription);
return this;
}
public Optional nextPageToken() {
return nextPageToken;
}
public SubscriptionListBuilder nextPageToken(String nextPageToken) {
return nextPageToken(Optional.ofNullable(nextPageToken));
}
@SuppressWarnings("unchecked")
public SubscriptionListBuilder nextPageToken(Optional extends String> nextPageToken) {
if (nextPageToken == null) {
throw new NullPointerException("nextPageToken");
}
this.nextPageToken = (Optional)nextPageToken;
return this;
}
public SubscriptionList build() {
List _subscriptions = (subscriptions != null) ? Collections.unmodifiableList(new ArrayList(subscriptions)) : Collections.emptyList();
return new Value(_subscriptions, nextPageToken);
}
public static SubscriptionListBuilder from(SubscriptionList v) {
return new SubscriptionListBuilder(v);
}
public static SubscriptionListBuilder from(SubscriptionListBuilder v) {
return new SubscriptionListBuilder(v);
}
private static final class Value implements SubscriptionList {
private final List subscriptions;
private final Optional nextPageToken;
private Value(@AutoMatter.Field("subscriptions") List subscriptions, @AutoMatter.Field("nextPageToken") Optional nextPageToken) {
if (nextPageToken == null) {
throw new NullPointerException("nextPageToken");
}
this.subscriptions = (subscriptions != null) ? subscriptions : Collections.emptyList();
this.nextPageToken = nextPageToken;
}
@AutoMatter.Field
@Override
public List subscriptions() {
return subscriptions;
}
@AutoMatter.Field
@Override
public Optional nextPageToken() {
return nextPageToken;
}
public SubscriptionListBuilder builder() {
return new SubscriptionListBuilder(this);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof SubscriptionList)) {
return false;
}
final SubscriptionList that = (SubscriptionList) o;
if (subscriptions != null ? !subscriptions.equals(that.subscriptions()) : that.subscriptions() != null) {
return false;
}
if (nextPageToken != null ? !nextPageToken.equals(that.nextPageToken()) : that.nextPageToken() != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (subscriptions != null ? subscriptions.hashCode() : 0);
result = 31 * result + (nextPageToken != null ? nextPageToken.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "SubscriptionList{" +
"subscriptions=" + subscriptions +
", nextPageToken=" + nextPageToken +
'}';
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy