public static Type createInstance ( String name , int maxLength , String pattern ) { synchronized ( STRING_PATTERN_TYPES ) { StringPatternType newType = new StringPatternType ( name , maxLength , pattern ) ; // Ensure that the named type does not already exist. StringPatternType oldType = STRING_PATTERN_TYPES . get ( name ) ; if ( ( oldType != null ) && ! oldType . equals ( newType ) ) { throw new IllegalArgumentException ( "The type '" + name + "' already exists and cannot be redefined." ) ; } else if ( ( oldType != null ) && oldType . equals ( newType ) ) { return oldType ; } else { // Add the newly created type to the map of all types. STRING_PATTERN_TYPES . put ( name , newType ) ; return newType ; } } }
Creates a new string pattern type with the specified name if it does not already exist .