]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/filter/NegativeNamespaceFilter.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / environment / filter / NegativeNamespaceFilter.java
1 package org.simantics.scl.compiler.environment.filter;
2
3 import gnu.trove.set.hash.THashSet;
4
5 public class NegativeNamespaceFilter implements NamespaceFilter {
6     THashSet<String> excludedValues;
7
8     public NegativeNamespaceFilter(THashSet<String> excludedValues) {
9         this.excludedValues = excludedValues;
10     }
11
12     @Override
13     public boolean isValueIncluded(String name) {
14         return !excludedValues.contains(name);
15     }
16     
17     @Override
18     public String toString() {
19         return "Exclude" + excludedValues.toString();
20     }
21
22     @Override
23     public boolean isSubsetOf(NamespaceFilter filter) {
24         if(filter == AcceptAllNamespaceFilter.INSTANCE)
25             return true;
26         if(filter instanceof NegativeNamespaceFilter) {
27             NegativeNamespaceFilter other = (NegativeNamespaceFilter)filter;
28             for(String name : other.excludedValues)
29                 if(!excludedValues.contains(name))
30                     return false;
31             return true;
32         }
33         return false;
34     }
35 }