1 package org.kuali.common.devops.jenkins.monitor.model; 2 3 import javax.validation.constraints.Min; 4 5 import org.kuali.common.core.build.ValidatingBuilder; 6 import org.kuali.common.core.validate.annotation.IdiotProofImmutable; 7 8 import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 9 10 @IdiotProofImmutable 11 @JsonDeserialize(builder = JenkinsSlave.Builder.class) 12 public final class JenkinsSlave { 13 14 private final String displayName; 15 private final String instanceId; 16 private final boolean jenkinsOnline; 17 private final boolean amazonOnline; 18 @Min(0) 19 private final long age; 20 21 private JenkinsSlave(Builder builder) { 22 this.instanceId = builder.instanceId; 23 this.displayName = builder.displayName; 24 this.jenkinsOnline = builder.jenkinsOnline; 25 this.amazonOnline = builder.amazonOnline; 26 this.age = builder.age; 27 } 28 29 public static Builder builder() { 30 return new Builder(); 31 } 32 33 public static class Builder extends ValidatingBuilder<JenkinsSlave> { 34 35 private String instanceId; 36 private boolean jenkinsOnline = false; 37 private boolean amazonOnline = false; 38 private long age = -1; 39 private String displayName; 40 41 public Builder withDisplayName(String displayName) { 42 this.displayName = displayName; 43 return this; 44 } 45 46 public Builder withInstanceId(String instanceId) { 47 this.instanceId = instanceId; 48 return this; 49 } 50 51 public Builder withJenkinsOnline(boolean jenkinsOnline) { 52 this.jenkinsOnline = jenkinsOnline; 53 return this; 54 } 55 56 public Builder withAmazonOnline(boolean amazonOnline) { 57 this.amazonOnline = amazonOnline; 58 return this; 59 } 60 61 public Builder withAge(long age) { 62 this.age = age; 63 return this; 64 } 65 66 @Override 67 public JenkinsSlave build() { 68 return validate(new JenkinsSlave(this)); 69 } 70 } 71 72 public String getInstanceId() { 73 return instanceId; 74 } 75 76 public boolean isJenkinsOnline() { 77 return jenkinsOnline; 78 } 79 80 public boolean isAmazonOnline() { 81 return amazonOnline; 82 } 83 84 public long getAge() { 85 return age; 86 } 87 88 public String getDisplayName() { 89 return displayName; 90 } 91 }