public static List < ValidationMessage > validateMediaType ( TagData data , List < ValidationMessage > messages ) { Object o = data . getAttribute ( "type" ) ; if ( o != null && o != TagData . REQUEST_TIME_VALUE && ! ( o instanceof MediaType ) ) { String type = Coercion . toString ( o ) ; try { // First allow shortcuts (matching enum names) MediaType mediaType = MediaType . getMediaTypeByName ( type ) ; if ( mediaType == null ) { mediaType = MediaType . getMediaTypeForContentType ( type ) ; } // Value is OK } catch ( MediaException err ) { messages = MinimalList . add ( messages , new ValidationMessage ( data . getId ( ) , err . getMessage ( ) ) ) ; } } return messages ; }
Checks that a type is a valid MediaType .