@Override public ResourceRecordSet getResult() { try { return builder.build(); } finally { builder = ResourceRecordSet.builder(); } }
public class ResourceRecordSetHandler extends ParseSax.HandlerForGeneratedRequestWithResult<ResourceRecordSet> { private StringBuilder currentText = new StringBuilder(); private ResourceRecordSet.Builder builder = ResourceRecordSet.builder(); @Override public ResourceRecordSet getResult() { try { return builder.build(); } finally { builder = ResourceRecordSet.builder(); } } @Override public void startElement(String url, String name, String qName, Attributes attributes) {} @Override public void endElement(String uri, String name, String qName) { if (qName.equals("Name")) { builder.name(currentOrNull(currentText)); } else if (qName.equals("Type")) { builder.type(currentOrNull(currentText)); } else if (qName.equals("TTL")) { builder.ttl(Integer.parseInt(currentOrNull(currentText))); } else if (qName.equals("Value")) { builder.add(currentOrNull(currentText)); } else if (qName.equals("HostedZoneId")) { builder.zoneId(currentOrNull(currentText)); } else if (qName.equals("SetIdentifier")) { builder.id(currentOrNull(currentText)); } else if (qName.equals("DNSName")) { builder.dnsName(currentOrNull(currentText)); } else if (qName.equals("Weight")) { builder.weight(Integer.parseInt(currentOrNull(currentText))); } else if (qName.equals("Region")) { builder.region(currentOrNull(currentText)); } currentText = new StringBuilder(); } @Override public void characters(char ch[], int start, int length) { currentText.append(ch, start, length); } }