001package org.kuali.common.devops.jenkins.scan;
002
003import javax.validation.constraints.Min;
004
005import org.kuali.common.core.build.ValidatingBuilder;
006import org.kuali.common.core.validate.annotation.IdiotProofImmutable;
007
008import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
009
010@IdiotProofImmutable
011@JsonDeserialize(builder = JobExecution.Builder.class)
012public final class JobExecution {
013
014        @Min(0)
015        private final int number;
016        @Min(0)
017        private final long startTime;
018        @Min(0)
019        private final long duration;
020        private final JobExecutionResult result;
021
022        private JobExecution(Builder builder) {
023                this.number = builder.number;
024                this.duration = builder.duration;
025                this.startTime = builder.startTime;
026                this.result = builder.result;
027        }
028
029        public static Builder builder() {
030                return new Builder();
031        }
032
033        public static class Builder extends ValidatingBuilder<JobExecution> {
034
035                private int number;
036                private long startTime;
037                private long duration;
038                private JobExecutionResult result;
039
040                public Builder withNumber(int number) {
041                        this.number = number;
042                        return this;
043                }
044
045                public Builder withDuration(long duration) {
046                        this.duration = duration;
047                        return this;
048                }
049
050                public Builder withStartTime(long startTime) {
051                        this.startTime = startTime;
052                        return this;
053                }
054
055                public Builder withResult(JobExecutionResult result) {
056                        this.result = result;
057                        return this;
058                }
059
060                @Override
061                public JobExecution build() {
062                        return validate(new JobExecution(this));
063                }
064        }
065
066        public int getNumber() {
067                return number;
068        }
069
070        public long getDuration() {
071                return duration;
072        }
073
074        public JobExecutionResult getResult() {
075                return result;
076        }
077
078        public long getStartTime() {
079                return startTime;
080        }
081
082}