001 package org.kuali.common.deploy.dns.model; 002 003 import org.kuali.common.util.Assert; 004 005 public class DnsmeContext { 006 007 private final int ttl; 008 private final String recordName; 009 private final String domainName; 010 private final RecordType recordType; 011 private final DnsmeCredentials credentials; 012 013 public static class Builder { 014 015 // Required 016 private final DnsmeCredentials credentials; 017 private final String recordName; 018 private final String domainName; 019 020 // Optional, default values are normally all that is needed 021 private int ttl = 60; 022 private RecordType recordType = RecordType.CNAME; 023 024 public Builder(DnsmeCredentials credentials, String recordName, String domainName) { 025 this.credentials = credentials; 026 this.recordName = recordName; 027 this.domainName = domainName; 028 } 029 030 public Builder ttl(int ttl) { 031 this.ttl = ttl; 032 return this; 033 } 034 035 public Builder recordType(RecordType recordType) { 036 this.recordType = recordType; 037 return this; 038 } 039 040 public DnsmeContext build() { 041 Assert.noBlanks(recordName, domainName); 042 Assert.noNulls(credentials, recordType); 043 return new DnsmeContext(this); 044 } 045 046 } 047 048 private DnsmeContext(Builder builder) { 049 this.credentials = builder.credentials; 050 this.recordName = builder.recordName; 051 this.ttl = builder.ttl; 052 this.recordType = builder.recordType; 053 this.domainName = builder.domainName; 054 } 055 056 public int getTtl() { 057 return ttl; 058 } 059 060 public String getRecordName() { 061 return recordName; 062 } 063 064 public String getDomainName() { 065 return domainName; 066 } 067 068 public RecordType getRecordType() { 069 return recordType; 070 } 071 072 public DnsmeCredentials getCredentials() { 073 return credentials; 074 } 075 076 }