1 package org.kuali.common.devops.model; 2 3 import java.util.Properties; 4 5 import org.kuali.common.core.build.ValidatingBuilder; 6 import org.kuali.common.core.validate.annotation.IdiotProofImmutable; 7 import org.kuali.common.util.project.model.ImmutableProject; 8 import org.kuali.common.util.project.model.Project; 9 import org.kuali.common.util.property.ImmutableProperties; 10 11 import com.google.common.base.Optional; 12 13 @IdiotProofImmutable 14 public final class Application { 15 16 private final ImmutableProject project; 17 private final ImmutableProperties manifest; 18 private final ImmutableProperties configuration; 19 private final Optional<Database> database; 20 private final Optional<Scm> scm; 21 22 private Application(Builder builder) { 23 this.project = ImmutableProject.copyOf(builder.project); 24 this.configuration = ImmutableProperties.copyOf(builder.configuration); 25 this.manifest = ImmutableProperties.copyOf(builder.manifest); 26 this.database = builder.database; 27 this.scm = builder.scm; 28 } 29 30 public static Application create(Project project, Properties manifest, Properties config, Optional<Database> database, Optional<Scm> scm) { 31 return builder().project(project).manifest(manifest).configuration(config).database(database).scm(scm).build(); 32 } 33 34 public static Builder builder() { 35 return new Builder(); 36 } 37 38 public static class Builder extends ValidatingBuilder<Application> { 39 40 private Project project; 41 private Properties configuration; 42 private Properties manifest; 43 private Optional<Database> database; 44 private Optional<Scm> scm; 45 46 public Builder scm(Optional<Scm> scm) { 47 this.scm = scm; 48 return this; 49 } 50 51 public Builder scm(Scm scm) { 52 return scm(Optional.of(scm)); 53 } 54 55 public Builder project(Project project) { 56 this.project = project; 57 return this; 58 } 59 60 public Builder configuration(Properties configuration) { 61 this.configuration = configuration; 62 return this; 63 } 64 65 public Builder manifest(Properties manifest) { 66 this.manifest = manifest; 67 return this; 68 } 69 70 public Builder database(Optional<Database> database) { 71 this.database = database; 72 return this; 73 } 74 75 public Builder database(Database database) { 76 return database(Optional.of(database)); 77 } 78 79 @Override 80 public Application build() { 81 return validate(new Application(this)); 82 } 83 84 public Project getProject() { 85 return project; 86 } 87 88 public void setProject(Project project) { 89 this.project = project; 90 } 91 92 public Optional<Database> getDatabase() { 93 return database; 94 } 95 96 public void setDatabase(Optional<Database> database) { 97 this.database = database; 98 } 99 100 public Optional<Scm> getScm() { 101 return scm; 102 } 103 104 public void setScm(Optional<Scm> scm) { 105 this.scm = scm; 106 } 107 108 public Properties getConfiguration() { 109 return configuration; 110 } 111 112 public void setConfiguration(Properties configuration) { 113 this.configuration = configuration; 114 } 115 116 public Properties getManifest() { 117 return manifest; 118 } 119 120 public void setManifest(Properties manifest) { 121 this.manifest = manifest; 122 } 123 } 124 125 public Project getProject() { 126 return project; 127 } 128 129 public Optional<Database> getDatabase() { 130 return database; 131 } 132 133 public Optional<Scm> getScm() { 134 return scm; 135 } 136 137 public ImmutableProperties getManifest() { 138 return manifest; 139 } 140 141 public ImmutableProperties getConfiguration() { 142 return configuration; 143 } 144 145 }