Task 2: Create Filter Sets

 

Solution

To create a filter set, first call the respective Create method of the FilterFactory class. You can choose between two ways of including the required filter in the filter set. Either you assign the filters respective already when you create the filter set, or you add them to the filter set subsequently using the method  IMutableFilterSet.addFilter() or IMutableFilterSet.addFilters().

 

Example

The following example demonstrates how you can create a filter set of the type OR. Using the createOrFilterSet() method, you create a filter set instance that, at first, does not contain any filters. The assignment of both filters fileAndFolderFilter and projectFilter to the new filter set is done using the addFilter()method.

 

 

IFilter fileAndFolderFilter = new FileAndFolderFilter();

IFilter projectFilter = new ProjectModelFilter();

 

IMutableFilterSet projectAndFileAndFolderFilter = FilterFactory.createOrFilterSet();

projectAndFileAndFolderFilter.addFilter(fileAndFolderFilter);

projectAndFileAndFolderFilter.addFilter(projectFilter);