View Javadoc

1   package org.kuali.common.deploy.dns.model;
2   
3   import org.kuali.common.util.Assert;
4   
5   public final class DnsContext {
6   
7   	private final String domain;
8   	private final String prefix;
9   	private final String subdomain;
10  	private final String hostname;
11  
12  	public String getDomain() {
13  		return domain;
14  	}
15  
16  	public String getPrefix() {
17  		return prefix;
18  	}
19  
20  	public String getSubdomain() {
21  		return subdomain;
22  	}
23  
24  	public String getHostname() {
25  		return hostname;
26  	}
27  
28  	public static class Builder {
29  
30  		// Required
31  		private final String prefix;
32  		private final String subdomain;
33  		private final String domain;
34  
35  		// Defaults to prefix + subdomain + domain if not provided
36  		private String hostname;
37  
38  		public Builder(String prefix, String subdomain, String domain) {
39  			this.prefix = prefix;
40  			this.subdomain = subdomain;
41  			this.domain = domain;
42  		}
43  
44  		public Builder hostname(String hostname) {
45  			this.hostname = hostname;
46  			return this;
47  		}
48  
49  		public DnsContext build() {
50  			Assert.noBlanks(prefix, subdomain, domain);
51  			if (hostname == null) {
52  				this.hostname = DnsUtils.getHostname(prefix, subdomain, domain);
53  			} else {
54  				Assert.noBlanks(hostname);
55  			}
56  			return new DnsContext(this);
57  		}
58  
59  	}
60  
61  	private DnsContext(Builder builder) {
62  		this.domain = builder.domain;
63  		this.hostname = builder.hostname;
64  		this.prefix = builder.prefix;
65  		this.subdomain = builder.subdomain;
66  	}
67  
68  }