public static List < Diagnostic > extractDiagnostics ( final List < Diagnostic > diagnostics , final int severity ) { ArrayList < Diagnostic > extract = new ArrayList <> ( ) ; for ( Diagnostic diagnostic : diagnostics ) { if ( diagnostic . getSeverity ( ) == severity ) { extract . add ( diagnostic ) ; } } return extract ; }
Extract diagnostics with a given severity from a list of Diagnostic objects . This is useful for picking errors out from a list of diagnostics for example .