static SuggestedItem findClosestSuggestedItem(List<SuggestedItem> r, String query) {
        for(SuggestedItem curItem : r) {
            if(LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine(String.format("item's searchUrl:%s;query=%s", curItem.item.getSearchUrl(), query));
            }
            if(curItem.item.getSearchUrl().contains(Util.rawEncode(query))) {
                return curItem;
            }
        }
        
        // couldn't find an item with the query in the url so just
        // return the first one
        return r.get(0);        
    }
static SuggestedItem findClosestSuggestedItem ( List < SuggestedItem > r , String query ) { for ( SuggestedItem curItem : r ) { if ( LOGGER . isLoggable ( Level . FINE ) ) { LOGGER . fine ( String . format ( "item's searchUrl:%s;query=%s" , curItem . item . getSearchUrl ( ) , query ) ) ; } if ( curItem . item . getSearchUrl ( ) . contains ( Util . rawEncode ( query ) ) ) { return curItem ; } } return r . get ( 0 ) ; }
When there are multiple suggested items, this method can narrow down the resultset
to the SuggestedItem that has a url that contains the query. This is useful is one
job has a display name that matches another job's project name.
@param r A list of Suggested items. It is assumed that there is at least one
SuggestedItem in r.
@param query A query string
@return Returns the SuggestedItem which has a search url that contains the query.
If no SuggestedItems have a search url which contains the query, then the first
SuggestedItem in the List is returned.