public List < Object > sortAndFilter ( ) { final List filteredList = getFilteredValue ( ) ; filteredList . clear ( ) ; rowMap = new HashMap <> ( ) ; rowNumbers = new HashMap <> ( ) ; final Collection < ? > values = ( Collection < ? > ) getValue ( ) ; if ( values == null || values . isEmpty ( ) ) { return filteredList ; } remapRows ( ) ; boolean filters = false ; for ( final SheetColumn col : getColumns ( ) ) { if ( ! LangUtils . isValueBlank ( col . getFilterValue ( ) ) ) { filters = true ; break ; } } final FacesContext context = FacesContext . getCurrentInstance ( ) ; final Map < String , Object > requestMap = context . getExternalContext ( ) . getRequestMap ( ) ; final String var = getVar ( ) ; if ( filters ) { // iterate and add those matching the filters for ( final Object obj : values ) { requestMap . put ( var , obj ) ; if ( matchesFilter ( obj ) ) { filteredList . add ( obj ) ; } } } else { filteredList . addAll ( values ) ; } final ValueExpression veSortBy = getValueExpression ( PropertyKeys . sortBy . name ( ) ) ; if ( veSortBy != null ) { Collections . sort ( filteredList , new BeanPropertyComparator ( veSortBy , var , convertSortOrder ( ) , null , isCaseSensitiveSort ( ) , Locale . ENGLISH , getNullSortOrder ( ) ) ) ; } // map filtered rows remapFilteredList ( filteredList ) ; return filteredList ; }
Sorts and filters the data