Class PatternsFilter

java.lang.Object
com.ibm.wala.util.config.PatternsFilter
All Implemented Interfaces:
StringFilter, Serializable, Predicate<String>

@NullMarked public class PatternsFilter extends Object implements StringFilter
A filter that accepts any String that matches any of a sequence of Patterns.

Patterns are matched as per Matcher.matches(). Thus, a String is in this set if at least one Pattern matches the entire String.

See Also:
  • Constructor Details

    • PatternsFilter

      public PatternsFilter(Stream<String> lines)
      Creates a PatternsFilter with the given regular expressions, one per Stream element.

      Any element that starts with "#" is discarded as a comment.

      This method does not take ownership of the given Stream. If that argument needs to be closed after use, then the caller is responsible for doing so.

      Parameters:
      lines - the regular expressions to addAll, one per line
    • PatternsFilter

      public PatternsFilter(InputStream input)
      Creates a PatternsFilter with the given regular expressions, one per line.

      Any line that starts with "#" is discarded as a comment.

      This method does not take ownership of the given InputStream. If that argument needs to be closed after use, then the caller is responsible for doing so.

      Parameters:
      input - the regular expressions to addAll, one per line
    • PatternsFilter

      public PatternsFilter(Path path) throws IOException
      Creates a PatternsFilter with the given regular expressions, one per line in the named file.

      Any line that starts with "#" is discarded as a comment.

      Parameters:
      path - the path to a file containing regular expressions to addAll, one per line
      Throws:
      IOException
    • PatternsFilter

      public PatternsFilter(File file) throws IOException
      Creates a PatternsFilter with the given regular expressions, one per line in the given file.

      Any line that starts with "#" is discarded as a comment.

      Parameters:
      file - a file containing regular expressions to addAll, one per line
      Throws:
      IOException
  • Method Details

    • builder

      public static PatternsFilter.Builder builder()
      Prepares to build a PatternsFilter.
      Returns:
      a PatternsFilter.Builder that can collect regular expressions and create a new SetOfClassPatterns
    • test

      public boolean test(String klassName)
      Specified by:
      test in interface Predicate<String>
    • toJson

      public List<String> toJson()
      Description copied from interface: StringFilter
      Provides a JSON-compatible representation of this filter for use in serialization.

      JSON-compatible types include String, List of a JSON-compatible type, Map from String to a JSON-compatible type, etc..

      Specified by:
      toJson in interface StringFilter
      Returns:
      a JSON-compatible representation of this filter