1 package com.puppycrawl.tools.checkstyle.api; 20 21 import java.util.HashSet ; 22 import java.util.Iterator ; 23 import java.util.Set ; 24 25 31 public class FilterSet 32 implements Filter 33 { 34 35 private final Set mFilters = new HashSet (); 36 37 41 public void addFilter(Filter aFilter) 42 { 43 mFilters.add(aFilter); 44 } 45 46 50 public void removeFilter(Filter aFilter) 51 { 52 mFilters.remove(aFilter); 53 } 54 55 59 protected Set getFilters() 60 { 61 return mFilters; 62 } 63 64 65 public String toString() 66 { 67 return mFilters.toString(); 68 } 69 70 71 public int hashCode() 72 { 73 return mFilters.hashCode(); 74 } 75 76 77 public boolean equals(Object aObject) 78 { 79 if (aObject instanceof FilterSet) { 80 final FilterSet other = (FilterSet) aObject; 81 return this.mFilters.equals(other.mFilters); 82 } 83 return false; 84 } 85 86 87 public boolean accept(AuditEvent aEvent) 88 { 89 final Iterator it = mFilters.iterator(); 90 while (it.hasNext()) { 91 final Filter filter = (Filter) it.next(); 92 if (!filter.accept(aEvent)) { 93 return false; 94 } 95 } 96 return true; 97 } 98 99 100 public void clear() 101 { 102 mFilters.clear(); 103 } 104 } 105 | Popular Tags |