package org.jxmpp.jid.parts;

import org.jxmpp.stringprep.XmppStringPrepUtil;
import org.jxmpp.stringprep.XmppStringprepException;

public class Domainpart extends Part {
   private Domainpart(String domain) {
      super(domain);
   }

   public static Domainpart from(String domain) throws XmppStringprepException {
      if (domain.length() > 0 && domain.charAt(domain.length() - 1) == '.') {
         domain = domain.substring(0, domain.length() - 1);
      }

      domain = XmppStringPrepUtil.domainprep(domain);
      assertNotLongerThan1023BytesOrEmpty(domain);
      return new Domainpart(domain);
   }
}
