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

com.arextest.schedule.sender.ReplaySendResult Maven / Gradle / Ivy

There is a newer version: 2.0.4
Show newest version
package com.arextest.schedule.sender;

import com.arextest.schedule.model.CaseSendStatusType;
import java.util.Collections;
import java.util.Map;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

/**
 * @author jmo
 * @since 2021/9/16
 */
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@ToString
public final class ReplaySendResult {

  private final String traceId;
  private final String remark;
  private final String url;
  private final Map headers;
  private final CaseSendStatusType statusType;

  private ReplaySendResult(String traceId, String remark, String url,
      CaseSendStatusType statusType) {
    this.traceId = traceId;
    this.remark = remark;
    this.url = url;
    this.headers = Collections.emptyMap();
    this.statusType = statusType;
  }

  public static ReplaySendResult success(String traceId, String remark, String url) {
    return new ReplaySendResult(traceId, remark, url, CaseSendStatusType.SUCCESS);
  }

  public static ReplaySendResult success(String traceId, String remark, String url,
      Map headers) {
    return new ReplaySendResult(traceId, remark, url, headers, CaseSendStatusType.SUCCESS);
  }

  public static ReplaySendResult failed(String remark) {
    return new ReplaySendResult(null, remark, null, CaseSendStatusType.EXCEPTION_FAILED);
  }

  public static ReplaySendResult failed(String remark, String url) {
    return new ReplaySendResult(null, remark, url, CaseSendStatusType.EXCEPTION_FAILED);
  }

  public static ReplaySendResult failed(String remark, String url, Map headers) {
    return new ReplaySendResult(null, remark, url, headers, CaseSendStatusType.EXCEPTION_FAILED);
  }

  public boolean success() {
    return statusType == CaseSendStatusType.SUCCESS;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy