Class BaseDnsWriter

All Implemented Interfaces:
Direct Known Subclasses:
CloudDnsWriter, DnsUpdateWriter, VoidDnsWriter

public abstract class BaseDnsWriter extends Object implements DnsWriter
A base implementation of DnsWriter that protects against multiple calls to commit().
  • Constructor Details

    • BaseDnsWriter

      public BaseDnsWriter()
  • Method Details

    • commit

      public final void commit()
      Description copied from interface: DnsWriter
      Commits the updates to the DNS server atomically.

      The user is responsible for making sure commit() isn't called twice. Implementations are encouraged to throw an error if commit() is called twice.

      Here's an example of how you would do that

       private boolean committed = false;
       void commit() {
         checkState(!committed, "commit() has already been called");
         committed = true;
         // ... actual commit implementation
      Specified by:
      commit in interface DnsWriter
    • commitUnchecked

      protected abstract void commitUnchecked()
      Commits DNS updates. This can never be called more than once.