X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fenvironment%2Ffilter%2FNegativeNamespaceFilter.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fenvironment%2Ffilter%2FNegativeNamespaceFilter.java;h=a0203d2d0217096f4e3e1c9c0a8b6b7b2302e743;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/filter/NegativeNamespaceFilter.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/filter/NegativeNamespaceFilter.java new file mode 100644 index 000000000..a0203d2d0 --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/filter/NegativeNamespaceFilter.java @@ -0,0 +1,35 @@ +package org.simantics.scl.compiler.environment.filter; + +import gnu.trove.set.hash.THashSet; + +public class NegativeNamespaceFilter implements NamespaceFilter { + THashSet excludedValues; + + public NegativeNamespaceFilter(THashSet excludedValues) { + this.excludedValues = excludedValues; + } + + @Override + public boolean isValueIncluded(String name) { + return !excludedValues.contains(name); + } + + @Override + public String toString() { + return "Exclude" + excludedValues.toString(); + } + + @Override + public boolean isSubsetOf(NamespaceFilter filter) { + if(filter == AcceptAllNamespaceFilter.INSTANCE) + return true; + if(filter instanceof NegativeNamespaceFilter) { + NegativeNamespaceFilter other = (NegativeNamespaceFilter)filter; + for(String name : other.excludedValues) + if(!excludedValues.contains(name)) + return false; + return true; + } + return false; + } +}