001 package org.kuali.common.deploy.dns.model;
002
003 import org.kuali.common.util.Assert;
004
005 public final class DnsContext {
006
007 private final String domain;
008 private final String prefix;
009 private final String subdomain;
010 private final String hostname;
011
012 public String getDomain() {
013 return domain;
014 }
015
016 public String getPrefix() {
017 return prefix;
018 }
019
020 public String getSubdomain() {
021 return subdomain;
022 }
023
024 public String getHostname() {
025 return hostname;
026 }
027
028 public static class Builder {
029
030 // Required
031 private final String prefix;
032 private final String subdomain;
033 private final String domain;
034
035 // Defaults to prefix + subdomain + domain if not provided
036 private String hostname;
037
038 public Builder(String prefix, String subdomain, String domain) {
039 this.prefix = prefix;
040 this.subdomain = subdomain;
041 this.domain = domain;
042 }
043
044 public Builder hostname(String hostname) {
045 this.hostname = hostname;
046 return this;
047 }
048
049 public DnsContext build() {
050 Assert.noBlanks(prefix, subdomain, domain);
051 if (hostname == null) {
052 this.hostname = DnsUtils.getHostname(prefix, subdomain, domain);
053 } else {
054 Assert.noBlanks(hostname);
055 }
056 return new DnsContext(this);
057 }
058
059 }
060
061 private DnsContext(Builder builder) {
062 this.domain = builder.domain;
063 this.hostname = builder.hostname;
064 this.prefix = builder.prefix;
065 this.subdomain = builder.subdomain;
066 }
067
068 }