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

com.sinch.sdk.domains.sms.models.DeliveryReportBatch Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.sinch.sdk.domains.sms.models;

import java.util.Collection;
import java.util.Objects;

/**
 * Common Definition to Delivery Report
 *
 * @since 1.0
 */
public abstract class DeliveryReportBatch extends BaseDeliveryReport {

  private final Collection statuses;
  private final Integer totalMessageCount;

  /**
   * @param batchId Required. The ID of the batch this delivery report belongs to.
   * @param clientReference The client identifier of the batch this delivery report belongs to, if
   *     set when submitting batch.
   * @param statuses Required. Array with status objects. Only status codes with at
   *     least one recipient will be listed.
   * @param totalMessageCount Required. The total number of messages in the batch.
   */
  public DeliveryReportBatch(
      String batchId,
      String clientReference,
      Collection statuses,
      Integer totalMessageCount) {
    super(batchId, clientReference);
    Objects.requireNonNull(statuses);
    Objects.requireNonNull(totalMessageCount);
    this.statuses = statuses;
    this.totalMessageCount = totalMessageCount;
  }

  public Collection getStatuses() {
    return statuses;
  }

  public Integer getTotalMessageCount() {
    return totalMessageCount;
  }

  @Override
  public String toString() {
    return "DeliveryReportBatch{"
        + "statuses="
        + statuses
        + ", totalMessageCount="
        + totalMessageCount
        + "} "
        + super.toString();
  }

  public abstract static class Builder> extends BaseDeliveryReport.Builder {
    protected Collection statuses;
    protected Integer totalMessageCount;

    public B setStatuses(Collection statuses) {
      this.statuses = statuses;
      return self();
    }

    public B setTotalMessageCount(Integer totalMessageCount) {
      this.totalMessageCount = totalMessageCount;
      return self();
    }

    @SuppressWarnings("unchecked")
    protected B self() {
      return (B) this;
    }

    public abstract DeliveryReportBatch build();
  }
}