com.spotify.google.cloud.pubsub.client.PublishRequestBuilder 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 javax.annotation.Generated;
@Generated("io.norberg.automatter.processor.AutoMatterProcessor")
final class PublishRequestBuilder {
private List messages;
public PublishRequestBuilder() {
}
private PublishRequestBuilder(PublishRequest v) {
List extends Message> _messages = v.messages();
this.messages = (_messages == null) ? null : new ArrayList(_messages);
}
private PublishRequestBuilder(PublishRequestBuilder v) {
this.messages = (v.messages == null) ? null : new ArrayList(v.messages);
}
public List messages() {
if (this.messages == null) {
this.messages = new ArrayList();
}
return messages;
}
public PublishRequestBuilder messages(List extends Message> messages) {
return messages((Collection extends Message>) messages);
}
public PublishRequestBuilder messages(Collection extends Message> messages) {
if (messages == null) {
throw new NullPointerException("messages");
}
for (Message item : messages) {
if (item == null) {
throw new NullPointerException("messages: null item");
}
}
this.messages = new ArrayList(messages);
return this;
}
public PublishRequestBuilder messages(Iterable extends Message> messages) {
if (messages == null) {
throw new NullPointerException("messages");
}
if (messages instanceof Collection) {
return messages((Collection extends Message>) messages);
}
return messages(messages.iterator());
}
public PublishRequestBuilder messages(Iterator extends Message> messages) {
if (messages == null) {
throw new NullPointerException("messages");
}
this.messages = new ArrayList();
while (messages.hasNext()) {
Message item = messages.next();
if (item == null) {
throw new NullPointerException("messages: null item");
}
this.messages.add(item);
}
return this;
}
public PublishRequestBuilder messages(Message... messages) {
if (messages == null) {
throw new NullPointerException("messages");
}
return messages(Arrays.asList(messages));
}
public PublishRequestBuilder addMessage(Message message) {
if (message == null) {
throw new NullPointerException("message");
}
if (this.messages == null) {
this.messages = new ArrayList();
}
messages.add(message);
return this;
}
public PublishRequest build() {
List _messages = (messages != null) ? Collections.unmodifiableList(new ArrayList(messages)) : Collections.emptyList();
return new Value(_messages);
}
public static PublishRequestBuilder from(PublishRequest v) {
return new PublishRequestBuilder(v);
}
public static PublishRequestBuilder from(PublishRequestBuilder v) {
return new PublishRequestBuilder(v);
}
private static final class Value implements PublishRequest {
private final List messages;
private Value(@AutoMatter.Field("messages") List messages) {
this.messages = (messages != null) ? messages : Collections.emptyList();
}
@AutoMatter.Field
@Override
public List messages() {
return messages;
}
public PublishRequestBuilder builder() {
return new PublishRequestBuilder(this);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof PublishRequest)) {
return false;
}
final PublishRequest that = (PublishRequest) o;
if (messages != null ? !messages.equals(that.messages()) : that.messages() != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (messages != null ? messages.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "PublishRequest{" +
"messages=" + messages +
'}';
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy