PeppolDocumentTypeIdentifierParts implements IPeppolDocumentTypeIdentifierParts { @Nonnull public static IPeppolDocumentTypeIdentifierParts extractFromString (@Nonnull @Nonempty final String sDocTypeID) { final IBusdoxDocumentTypeIdentifierParts aBusdoxParts = BusdoxDocumentTypeIdentifierParts.extractFromString (sDocTypeID); final String sSubTypeIdentifier = aBusdoxParts.getSubTypeIdentifier (); if (StringHelper.hasNoText (sSubTypeIdentifier)) throw new IllegalArgumentException ("The passed document identifier has an empty sub type identifier which is not PEPPOL compliant!"); final String [] aSubTypeParts = RegExHelper.getSplitToArray (sSubTypeIdentifier, VERSION_SEPARATOR, 2); if (aSubTypeParts.length < 2) throw new IllegalArgumentException ("The sub type identifier '" + sSubTypeIdentifier + "' is missing the separation between customization ID and version!"); final String sCustomizationID = aSubTypeParts[0]; if (StringHelper.hasNoText (sCustomizationID)) throw new IllegalArgumentException ("The sub type identifier '" + sSubTypeIdentifier + "' contains an empty customization ID!"); final String sVersion = aSubTypeParts[1]; if (StringHelper.hasNoText (sVersion)) throw new IllegalArgumentException ("The sub type identifier '" + sSubTypeIdentifier + "' contains an empty version!"); return new PeppolDocumentTypeIdentifierParts (aBusdoxParts, sCustomizationID, sVersion); } private  PeppolDocumentTypeIdentifierParts(@Nonnull final IBusdoxDocumentTypeIdentifierParts aBusdoxParts,
                                             @Nonnull @Nonempty final String sCustomizationID,
                                             @Nonnull @Nonempty final String sVersion);  PeppolDocumentTypeIdentifierParts(@Nonnull @Nonempty final String sRootNS,
                                            @Nonnull @Nonempty final String sLocalName,
                                            @Nonnull @Nonempty final String sCustomizationID,
                                            @Nonnull @Nonempty final String sVersion); @Nonnull @Nonempty String getRootNS(); @Nonnull @Nonempty String getLocalName(); @Nonnull @Nonempty String getSubTypeIdentifier(); @Nonnull @Nonempty String getCustomizationID(); @Nonnull @Nonempty String getVersion(); @Nonnull @Nonempty String getAsDocumentTypeIdentifierValue(); @Override String toString(); @Nonnull static IPeppolDocumentTypeIdentifierParts extractFromString(@Nonnull @Nonempty final String sDocTypeID); @Nullable static IPeppolDocumentTypeIdentifierParts extractFromIdentifier(@Nonnull final IDocumentTypeIdentifier aIdentifier); static final String VERSION_SEPARATOR; }
@Test public void testInvalid () { try { PeppolDocumentTypeIdentifierParts.extractFromString ("root::local"); fail (); } catch (final IllegalArgumentException ex) {} try { PeppolDocumentTypeIdentifierParts.extractFromString ("root::local##customization"); fail (); } catch (final IllegalArgumentException ex) {} try { PeppolDocumentTypeIdentifierParts.extractFromString ("root::local##customization::"); fail (); } catch (final IllegalArgumentException ex) {} try { PeppolDocumentTypeIdentifierParts.extractFromString ("root::local##::version"); fail (); } catch (final IllegalArgumentException ex) {} assertNotNull (PeppolDocumentTypeIdentifierParts.extractFromString ("root::local##customization::version")); }