MessageType parseAlternative ( String text ) { //try with custom types if ( text . charAt ( 0 ) == ' ' ) { int end = text . indexOf ( ' ' , 1 ) ; return new MessageType . CustomType ( text . substring ( 1 , end ) ) ; } //try with simple types for ( SimpleType st : SimpleType . values ( ) ) { if ( text . equals ( st . kindName ( ) ) ) { return st ; } } //try with compound types for ( CompoundType . Kind ck : CompoundType . Kind . values ( ) ) { if ( text . startsWith ( ck . kindName ) ) { MessageType elemtype = parseAlternative ( text . substring ( ck . kindName . length ( ) + 1 ) . trim ( ) ) ; return new CompoundType ( ck , elemtype ) ; } } //try with union types for ( UnionType . Kind uk : UnionType . Kind . values ( ) ) { if ( text . startsWith ( uk . kindName ) ) { return new UnionType ( uk ) ; } } //no match - report a warning System . err . println ( "WARNING - unrecognized type: " + text ) ; return SimpleType . UNKNOWN ; }
Parse a subset of the type comment ; valid matches are simple types compound types union types and custom types .