View Javadoc
1   package org.kuali.common.devops.jenkins.scan;
2   
3   import static com.google.common.collect.Lists.newArrayList;
4   
5   import java.util.List;
6   
7   import org.kuali.common.core.build.ValidatingBuilder;
8   import org.kuali.common.core.validate.annotation.IdiotProofImmutable;
9   
10  import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
11  import com.google.common.collect.ImmutableList;
12  
13  @IdiotProofImmutable
14  @JsonDeserialize(builder = Job.Builder.class)
15  public final class Job {
16  
17  	private final String name;
18  	private final ImmutableList<JobExecution> executions;
19  
20  	private Job(Builder builder) {
21  		this.name = builder.name;
22  		this.executions = ImmutableList.copyOf(builder.executions);
23  	}
24  
25  	public static Job build(String name, List<JobExecution> executions) {
26  		return builder().withName(name).withExecutions(executions).build();
27  	}
28  
29  	public static Job build(String name) {
30  		return build(name, ImmutableList.<JobExecution> of());
31  	}
32  
33  	public static Builder builder() {
34  		return new Builder();
35  	}
36  
37  	public static class Builder extends ValidatingBuilder<Job> {
38  
39  		private String name;
40  		private List<JobExecution> executions = newArrayList();
41  
42  		public Builder withName(String name) {
43  			this.name = name;
44  			return this;
45  		}
46  
47  		public Builder withExecutions(List<JobExecution> executions) {
48  			this.executions = executions;
49  			return this;
50  		}
51  
52  		@Override
53  		public Job build() {
54  			return validate(new Job(this));
55  		}
56  	}
57  
58  	public String getName() {
59  		return name;
60  	}
61  
62  	public List<JobExecution> getExecutions() {
63  		return executions;
64  	}
65  
66  }