List<String> applyNameFilter(List<String> collections){
  if (filterType != FilterType.name || filter == null)   return collections;
  String regexFilter=(!filter.endsWith(".*") && filter.endsWith("*")) ? filter.substring(0,filter.length() - 1) + ".*" : filter;
  if (!regexFilter.startsWith("(?i)"))   regexFilter="(?i)" + regexFilter;
  Pattern filterRegex=Pattern.compile(regexFilter);
  List<String> filtered=new ArrayList<String>();
  for (  String next : collections) {
    if (matches(filterRegex,next))     filtered.add(next);
  }
  return filtered;
}

List < String > applyNameFilter ( List < String > collections ) { if ( filterType != FilterType . name || filter == null ) return collections ; String regexFilter = ( ! filter . endsWith ( ".*" ) && filter . endsWith ( "*" ) ) ? filter . substring ( 0 , filter . length ( ) - 1 ) + ".*" : filter ; if ( ! regexFilter . startsWith ( "(?i)" ) ) regexFilter = "(?i)" + regexFilter ; Pattern filterRegex = Pattern . compile ( regexFilter ) ; List < String > filtered = new ArrayList < String > ( ) ; for ( String next : collections ) { if ( matches ( filterRegex , next ) ) filtered . add ( next ) ; } return filtered ; }
filters a list of collections by name if applicable .
