
co.spraybot.messagerunner.builders.ReportSummaryBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of message-runner Show documentation
Show all versions of message-runner Show documentation
A micro-framework to allow easily passing specific Vert.x messages to specific addresses for processing of those messages.
The newest version!
package co.spraybot.messagerunner.builders;
import co.spraybot.messagerunner.ReportSummary;
import javax.annotation.Nullable;
import java.time.Duration;
import java.time.LocalDateTime;
public class ReportSummaryBuilder {
private LocalDateTime startedAt;
private LocalDateTime endedAt;
private Integer itemCount;
private Throwable failedCause;
public ReportSummaryBuilder startedAt(LocalDateTime dateTime) {
startedAt = dateTime;
return this;
}
public ReportSummaryBuilder itemCount(int itemCount) {
this.itemCount = itemCount;
return this;
}
public ReportSummaryBuilder reportFailed(Throwable throwable) {
failedCause = throwable;
return this;
}
public ReportSummaryBuilder endedAt(LocalDateTime dateTime) {
endedAt = dateTime;
return this;
}
public ReportSummary build() {
ReportSummary summary = new ReportSummary() {
private LocalDateTime reportDate;
private Integer itemCount;
private Duration executionTime;
private Throwable cause;
private ReportSummary init(LocalDateTime reportDate, Duration executionTime, Integer itemCount, Throwable cause) {
this.reportDate = reportDate;
this.executionTime = executionTime;
this.itemCount = itemCount;
this.cause = cause;
return this;
}
@Override
public LocalDateTime getReportDate() {
return reportDate;
}
@Override
public int getItemCount() {
return itemCount;
}
@Override
public Duration getExecutionTime() {
return executionTime;
}
@Override
public boolean isSucceeded() {
return cause == null;
}
@Override
public boolean isFailed() {
return cause != null;
}
@Nullable
@Override
public Throwable getCause() {
return cause;
}
}.init(startedAt, Duration.between(startedAt, endedAt), itemCount, failedCause);
startedAt = null;
endedAt = null;
itemCount = null;
failedCause = null;
return summary;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy