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

tech.grasshopper.pdf.pojo.cucumber.BaseEntity Maven / Gradle / Ivy

The newest version!
package tech.grasshopper.pdf.pojo.cucumber;

import java.time.Duration;
import java.time.LocalDateTime;

import lombok.Data;
import lombok.experimental.SuperBuilder;
import tech.grasshopper.pdf.exception.PdfReportException;

@Data
@SuperBuilder
public abstract class BaseEntity {

	protected String name;

	protected Status status;

	protected LocalDateTime startTime;
	protected LocalDateTime endTime;

	public Duration calculatedDuration() {

		return Duration.between(startTime, endTime);
	}

	protected void checkTimeData() {

		if (startTime == null)
			throw new PdfReportException("Start Time not present for " + this.getClass().getName() + " - " + getName());

		if (endTime == null)
			throw new PdfReportException("End Time not present for " + this.getClass().getName() + " - " + getName());

		if (startTime.compareTo(endTime) > 0)
			throw new PdfReportException(
					"Start Time is later than End time for " + this.getClass().getName() + " - " + getName());
	}

	public void checkData() {
		checkTimeData();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy