title: Filtering out specific objects from a search query in Alfresco using Java
body: <p>I have a HashSet containing all groups I've retrieved from my database.  I've been asked to filter this result by removing two specific groups.  It seems trivial but I can't seem to come up with a solid solution for storing the specific groups I want to filter out.</p>
  
  <p>My idea is to just create an array containing references to the two groups I need to filter out.  I can then filter out my search query with whatever is in the array.  My concern is that in the future they may ask to filter out more groups and maybe an array may not be a good idea.  </p>
  
  <pre><code>//Creates the array containing groups to filter out
  
  String[] hiddenGroups = {"group1","group2"};
  //retrieves all groups
  Set&lt;String&gt;allGroups = new HashSet&lt;String&gt;();
  allGroups.addAll(authorityService.getAllAuthorities(AuthorityType.GROUP);
  List&lt;String&gt;results = new ArrayList&lt;String&gt;();
  
  //filters out specified groups 
  for (String group : allGroups) {
    boolean isHidden = false;
    for (String hiddenGroup : hiddenGroups) {
      if (hiddenGroup.equalsIgnorecase(group)) {
        isHidden = true;
      }
    }
    if (!isHidden){
      results.add(group);
    }
  }
  </code></pre>