Package org.forgerock.util
Class BlackAndWhitelistFilter
- java.lang.Object
-
- org.forgerock.util.BlackAndWhitelistFilter
-
public class BlackAndWhitelistFilter extends Object implements Predicate<String>
This class can be used for filtering string elements by using blacklists and/or whitelists.Tested elements are permitted if:
- The whitelist is empty and the tested element does not match a blacklist entry.
- The tested element matches an entry in the whitelist and does not match a blacklist entry.
Once created, call
test(String)
} to know if aString
is accepted by the filter.- See Also:
Pattern.compile(String)
-
-
Constructor Summary
Constructors Constructor Description BlackAndWhitelistFilter(Collection<Pattern> regExpBlacklist, Collection<Pattern> regExpWhitelist)
Creates a newBlackAndWhitelistFilter
with provided collections.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
test(String string)
Returnstrue
if the provided string is accepted by this filter,false
otherwise.
-
-
-
Constructor Detail
-
BlackAndWhitelistFilter
public BlackAndWhitelistFilter(Collection<Pattern> regExpBlacklist, Collection<Pattern> regExpWhitelist)
Creates a newBlackAndWhitelistFilter
with provided collections.
-
-
Method Detail
-
test
public boolean test(String string)
Returnstrue
if the provided string is accepted by this filter,false
otherwise.A string value is excluded by the filter if the whitelist is non-empty and it is not in the whitelist, or if the string is in the blacklist.
-
-