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

com.spotify.google.cloud.pubsub.client.PublishResponseBuilder Maven / Gradle / Ivy

There is a newer version: 1.34
Show newest version
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 PublishResponseBuilder {
  private List messageIds;

  public PublishResponseBuilder() {
  }

  private PublishResponseBuilder(PublishResponse v) {
    List _messageIds = v.messageIds();
    this.messageIds = (_messageIds == null) ? null : new ArrayList(_messageIds);
  }

  private PublishResponseBuilder(PublishResponseBuilder v) {
    this.messageIds = (v.messageIds == null) ? null : new ArrayList(v.messageIds);
  }

  public List messageIds() {
    if (this.messageIds == null) {
      this.messageIds = new ArrayList();
    }
    return messageIds;
  }

  public PublishResponseBuilder messageIds(List messageIds) {
    return messageIds((Collection) messageIds);
  }

  public PublishResponseBuilder messageIds(Collection messageIds) {
    if (messageIds == null) {
      throw new NullPointerException("messageIds");
    }
    for (String item : messageIds) {
      if (item == null) {
        throw new NullPointerException("messageIds: null item");
      }
    }
    this.messageIds = new ArrayList(messageIds);
    return this;
  }

  public PublishResponseBuilder messageIds(Iterable messageIds) {
    if (messageIds == null) {
      throw new NullPointerException("messageIds");
    }
    if (messageIds instanceof Collection) {
      return messageIds((Collection) messageIds);
    }
    return messageIds(messageIds.iterator());
  }

  public PublishResponseBuilder messageIds(Iterator messageIds) {
    if (messageIds == null) {
      throw new NullPointerException("messageIds");
    }
    this.messageIds = new ArrayList();
    while (messageIds.hasNext()) {
      String item = messageIds.next();
      if (item == null) {
        throw new NullPointerException("messageIds: null item");
      }
      this.messageIds.add(item);
    }
    return this;
  }

  @SafeVarargs
  public final PublishResponseBuilder messageIds(String... messageIds) {
    if (messageIds == null) {
      throw new NullPointerException("messageIds");
    }
    return messageIds(Arrays.asList(messageIds));
  }

  public PublishResponseBuilder addMessageId(String messageId) {
    if (messageId == null) {
      throw new NullPointerException("messageId");
    }
    if (this.messageIds == null) {
      this.messageIds = new ArrayList();
    }
    messageIds.add(messageId);
    return this;
  }

  public PublishResponse build() {
    List _messageIds = (messageIds != null) ? Collections.unmodifiableList(new ArrayList(messageIds)) : Collections.emptyList();
    return new Value(_messageIds);
  }

  public static PublishResponseBuilder from(PublishResponse v) {
    return new PublishResponseBuilder(v);
  }

  public static PublishResponseBuilder from(PublishResponseBuilder v) {
    return new PublishResponseBuilder(v);
  }

  private static final class Value implements PublishResponse {
    private final List messageIds;

    private Value(@AutoMatter.Field("messageIds") List messageIds) {
      this.messageIds = (messageIds != null) ? messageIds : Collections.emptyList();
    }

    @AutoMatter.Field
    @Override
    public List messageIds() {
      return messageIds;
    }

    public PublishResponseBuilder builder() {
      return new PublishResponseBuilder(this);
    }

    @Override
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (!(o instanceof PublishResponse)) {
        return false;
      }
      final PublishResponse that = (PublishResponse) o;
      if (messageIds != null ? !messageIds.equals(that.messageIds()) : that.messageIds() != null) {
        return false;
      }
      return true;
    }

    @Override
    public int hashCode() {
      int result = 1;
      long temp;
      result = 31 * result + (messageIds != null ? messageIds.hashCode() : 0);
      return result;
    }

    @Override
    public String toString() {
      return "PublishResponse{" +
      "messageIds=" + messageIds +
      '}';
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy