@Test public void parseUnqualified() { Assert.assertEquals( new DhisFhirResourceId( "a1234567890" ), DhisFhirResourceId.parse( "a1234567890" ) ); }
@Nonnull public static DhisFhirResourceId parse( @Nonnull String value ) throws IllegalArgumentException { final int firstIndex = value.indexOf( '-' ); if ( firstIndex < 0 ) { return new DhisFhirResourceId( value ); } if ( firstIndex == 0 ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final int secondIndex = value.indexOf( '-', firstIndex + 1 ); if ( secondIndex < 0 ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final DhisResourceType type = DhisResourceType.getByAbbreviation( value.substring( 0, firstIndex ) ); if ( type == null ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final String id = value.substring( firstIndex + 1, secondIndex ); if ( StringUtils.isBlank( id ) || !StringUtils.isAlphanumeric( id ) ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final UUID ruleId; try { final Matcher matcher = UUID_PATTERN.matcher( value.substring( secondIndex + 1 ) ); if ( !matcher.matches() ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } ruleId = UUID.fromString( matcher.replaceAll( "$1-$2-$3-$4-$5" ) ); } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } return new DhisFhirResourceId( type, id, ruleId ); }
DhisFhirResourceId implements Serializable { @Nonnull public static DhisFhirResourceId parse( @Nonnull String value ) throws IllegalArgumentException { final int firstIndex = value.indexOf( '-' ); if ( firstIndex < 0 ) { return new DhisFhirResourceId( value ); } if ( firstIndex == 0 ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final int secondIndex = value.indexOf( '-', firstIndex + 1 ); if ( secondIndex < 0 ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final DhisResourceType type = DhisResourceType.getByAbbreviation( value.substring( 0, firstIndex ) ); if ( type == null ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final String id = value.substring( firstIndex + 1, secondIndex ); if ( StringUtils.isBlank( id ) || !StringUtils.isAlphanumeric( id ) ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final UUID ruleId; try { final Matcher matcher = UUID_PATTERN.matcher( value.substring( secondIndex + 1 ) ); if ( !matcher.matches() ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } ruleId = UUID.fromString( matcher.replaceAll( "$1-$2-$3-$4-$5" ) ); } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } return new DhisFhirResourceId( type, id, ruleId ); } }
DhisFhirResourceId implements Serializable { @Nonnull public static DhisFhirResourceId parse( @Nonnull String value ) throws IllegalArgumentException { final int firstIndex = value.indexOf( '-' ); if ( firstIndex < 0 ) { return new DhisFhirResourceId( value ); } if ( firstIndex == 0 ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final int secondIndex = value.indexOf( '-', firstIndex + 1 ); if ( secondIndex < 0 ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final DhisResourceType type = DhisResourceType.getByAbbreviation( value.substring( 0, firstIndex ) ); if ( type == null ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final String id = value.substring( firstIndex + 1, secondIndex ); if ( StringUtils.isBlank( id ) || !StringUtils.isAlphanumeric( id ) ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final UUID ruleId; try { final Matcher matcher = UUID_PATTERN.matcher( value.substring( secondIndex + 1 ) ); if ( !matcher.matches() ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } ruleId = UUID.fromString( matcher.replaceAll( "$1-$2-$3-$4-$5" ) ); } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } return new DhisFhirResourceId( type, id, ruleId ); } DhisFhirResourceId( @Nullable DhisResourceType type, @Nonnull String id, @Nullable UUID ruleId );  DhisFhirResourceId( @Nonnull String id ); }
DhisFhirResourceId implements Serializable { @Nonnull public static DhisFhirResourceId parse( @Nonnull String value ) throws IllegalArgumentException { final int firstIndex = value.indexOf( '-' ); if ( firstIndex < 0 ) { return new DhisFhirResourceId( value ); } if ( firstIndex == 0 ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final int secondIndex = value.indexOf( '-', firstIndex + 1 ); if ( secondIndex < 0 ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final DhisResourceType type = DhisResourceType.getByAbbreviation( value.substring( 0, firstIndex ) ); if ( type == null ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final String id = value.substring( firstIndex + 1, secondIndex ); if ( StringUtils.isBlank( id ) || !StringUtils.isAlphanumeric( id ) ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final UUID ruleId; try { final Matcher matcher = UUID_PATTERN.matcher( value.substring( secondIndex + 1 ) ); if ( !matcher.matches() ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } ruleId = UUID.fromString( matcher.replaceAll( "$1-$2-$3-$4-$5" ) ); } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } return new DhisFhirResourceId( type, id, ruleId ); } DhisFhirResourceId( @Nullable DhisResourceType type, @Nonnull String id, @Nullable UUID ruleId );  DhisFhirResourceId( @Nonnull String id ); DhisResourceType getType(); @Nonnull String getId(); UUID getRuleId(); @Nonnull DhisResourceId getDhisResourceId(); boolean isQualified(); @Nonnull DhisFhirResourceId toQualified( @Nonnull DhisResourceType type, @Nonnull UUID ruleId ); @Override boolean equals( Object o ); @Override int hashCode(); @Override @Nonnull String toString(); @Nonnull static String toString( @Nullable DhisResourceType type, @Nonnull String id, @Nullable UUID ruleId ); static boolean isValid( @Nullable String value ); @Nonnull static DhisFhirResourceId parse( @Nonnull String value ); }
DhisFhirResourceId implements Serializable { @Nonnull public static DhisFhirResourceId parse( @Nonnull String value ) throws IllegalArgumentException { final int firstIndex = value.indexOf( '-' ); if ( firstIndex < 0 ) { return new DhisFhirResourceId( value ); } if ( firstIndex == 0 ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final int secondIndex = value.indexOf( '-', firstIndex + 1 ); if ( secondIndex < 0 ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final DhisResourceType type = DhisResourceType.getByAbbreviation( value.substring( 0, firstIndex ) ); if ( type == null ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final String id = value.substring( firstIndex + 1, secondIndex ); if ( StringUtils.isBlank( id ) || !StringUtils.isAlphanumeric( id ) ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } final UUID ruleId; try { final Matcher matcher = UUID_PATTERN.matcher( value.substring( secondIndex + 1 ) ); if ( !matcher.matches() ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } ruleId = UUID.fromString( matcher.replaceAll( "$1-$2-$3-$4-$5" ) ); } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException( "Invalid DHIS FHIR ID: " + value ); } return new DhisFhirResourceId( type, id, ruleId ); } DhisFhirResourceId( @Nullable DhisResourceType type, @Nonnull String id, @Nullable UUID ruleId );  DhisFhirResourceId( @Nonnull String id ); DhisResourceType getType(); @Nonnull String getId(); UUID getRuleId(); @Nonnull DhisResourceId getDhisResourceId(); boolean isQualified(); @Nonnull DhisFhirResourceId toQualified( @Nonnull DhisResourceType type, @Nonnull UUID ruleId ); @Override boolean equals( Object o ); @Override int hashCode(); @Override @Nonnull String toString(); @Nonnull static String toString( @Nullable DhisResourceType type, @Nonnull String id, @Nullable UUID ruleId ); static boolean isValid( @Nullable String value ); @Nonnull static DhisFhirResourceId parse( @Nonnull String value );  }