@Test public void transformsTXTRecordSet() { Record input = new Record(); input.name = "denominator.io"; input.type = "TXT"; input.ttl = 3600; input.data("Hello DNS"); assertThat(CloudDNSFunctions.toRDataMap(input)) .isEqualTo(TXTData.create("Hello DNS")); }
static Map<String, Object> toRDataMap(Record record) { if ("MX".equals(record.type)) { return MXData.create(record.priority, record.data()); } else if ("TXT".equals(record.type)) { return TXTData.create(record.data()); } else if ("SRV".equals(record.type)) { List<String> rdata = split(' ', record.data()); return SRVData.builder() .priority(record.priority) .weight(Integer.valueOf(rdata.get(0))) .port(Integer.valueOf(rdata.get(1))) .target(rdata.get(2)).build(); } else if ("SOA".equals(record.type)) { List<String> threeParts = split(' ', record.data()); return SOAData.builder() .mname(threeParts.get(0)) .rname(threeParts.get(1)) .serial(Integer.valueOf(threeParts.get(2))) .refresh(record.ttl) .retry(record.ttl) .expire(record.ttl).minimum(record.ttl).build(); } else { return Util.toMap(record.type, record.data()); } }
CloudDNSFunctions { static Map<String, Object> toRDataMap(Record record) { if ("MX".equals(record.type)) { return MXData.create(record.priority, record.data()); } else if ("TXT".equals(record.type)) { return TXTData.create(record.data()); } else if ("SRV".equals(record.type)) { List<String> rdata = split(' ', record.data()); return SRVData.builder() .priority(record.priority) .weight(Integer.valueOf(rdata.get(0))) .port(Integer.valueOf(rdata.get(1))) .target(rdata.get(2)).build(); } else if ("SOA".equals(record.type)) { List<String> threeParts = split(' ', record.data()); return SOAData.builder() .mname(threeParts.get(0)) .rname(threeParts.get(1)) .serial(Integer.valueOf(threeParts.get(2))) .refresh(record.ttl) .retry(record.ttl) .expire(record.ttl).minimum(record.ttl).build(); } else { return Util.toMap(record.type, record.data()); } } }
CloudDNSFunctions { static Map<String, Object> toRDataMap(Record record) { if ("MX".equals(record.type)) { return MXData.create(record.priority, record.data()); } else if ("TXT".equals(record.type)) { return TXTData.create(record.data()); } else if ("SRV".equals(record.type)) { List<String> rdata = split(' ', record.data()); return SRVData.builder() .priority(record.priority) .weight(Integer.valueOf(rdata.get(0))) .port(Integer.valueOf(rdata.get(1))) .target(rdata.get(2)).build(); } else if ("SOA".equals(record.type)) { List<String> threeParts = split(' ', record.data()); return SOAData.builder() .mname(threeParts.get(0)) .rname(threeParts.get(1)) .serial(Integer.valueOf(threeParts.get(2))) .refresh(record.ttl) .retry(record.ttl) .expire(record.ttl).minimum(record.ttl).build(); } else { return Util.toMap(record.type, record.data()); } } private  CloudDNSFunctions(); }
CloudDNSFunctions { static Map<String, Object> toRDataMap(Record record) { if ("MX".equals(record.type)) { return MXData.create(record.priority, record.data()); } else if ("TXT".equals(record.type)) { return TXTData.create(record.data()); } else if ("SRV".equals(record.type)) { List<String> rdata = split(' ', record.data()); return SRVData.builder() .priority(record.priority) .weight(Integer.valueOf(rdata.get(0))) .port(Integer.valueOf(rdata.get(1))) .target(rdata.get(2)).build(); } else if ("SOA".equals(record.type)) { List<String> threeParts = split(' ', record.data()); return SOAData.builder() .mname(threeParts.get(0)) .rname(threeParts.get(1)) .serial(Integer.valueOf(threeParts.get(2))) .refresh(record.ttl) .retry(record.ttl) .expire(record.ttl).minimum(record.ttl).build(); } else { return Util.toMap(record.type, record.data()); } } private  CloudDNSFunctions();  }
CloudDNSFunctions { static Map<String, Object> toRDataMap(Record record) { if ("MX".equals(record.type)) { return MXData.create(record.priority, record.data()); } else if ("TXT".equals(record.type)) { return TXTData.create(record.data()); } else if ("SRV".equals(record.type)) { List<String> rdata = split(' ', record.data()); return SRVData.builder() .priority(record.priority) .weight(Integer.valueOf(rdata.get(0))) .port(Integer.valueOf(rdata.get(1))) .target(rdata.get(2)).build(); } else if ("SOA".equals(record.type)) { List<String> threeParts = split(' ', record.data()); return SOAData.builder() .mname(threeParts.get(0)) .rname(threeParts.get(1)) .serial(Integer.valueOf(threeParts.get(2))) .refresh(record.ttl) .retry(record.ttl) .expire(record.ttl).minimum(record.ttl).build(); } else { return Util.toMap(record.type, record.data()); } } private  CloudDNSFunctions();   }