Class RowFilter

  • All Implemented Interfaces:
    Predicate<Row>

    public abstract class RowFilter
    extends Object
    implements Predicate<Row>
    The RowFilter class encapsulates a filter test for a table row. This can be used by the apply(Iterable) method to create an Iterable over a table which returns only rows matching some criteria.
    Author:
    Patricia Donaldson, Xerox Corporation
    Usage:
    General: This class is general use.
    • Constructor Detail

      • RowFilter

        public RowFilter()
    • Method Detail

      • matches

        public abstract boolean matches​(Row row)
        Returns true if the given table row matches the Filter criteria, false otherwise.
        Parameters:
        row - current row to test for inclusion in the filter
      • apply

        public Iterable<Row> apply​(Iterable<? extends Row> iterable)
        Returns an iterable which filters the given iterable based on this filter.
        Parameters:
        iterable - row iterable to filter
        Returns:
        a filtering iterable
      • filter

        public Stream<Row> filter​(Iterable<? extends Row> iterable)
        Convenience method to apply this filter to the given iterable and return it as a Stream.
      • matchPattern

        public static RowFilter matchPattern​(Map<String,​?> rowPattern)
        Creates a filter based on a row pattern.
        Parameters:
        rowPattern - Map from column names to the values to be matched. A table row will match the target if Objects.equals(rowPattern.get(s), row.get(s)) for all column names in the pattern map.
        Returns:
        a filter which matches table rows which match the values in the row pattern
      • matchPattern

        public static RowFilter matchPattern​(Column columnPattern,
                                             Object valuePattern)
        Creates a filter based on a single value row pattern.
        Parameters:
        columnPattern - column to be matched
        valuePattern - value to be matched. A table row will match the target if Objects.equals(valuePattern, row.get(columnPattern.getName())).
        Returns:
        a filter which matches table rows which match the value in the row pattern
      • invert

        public static RowFilter invert​(RowFilter filter)
        Creates a filter which inverts the sense of the given filter (rows which are matched by the given filter will not be matched by the returned filter, and vice versa).
        Parameters:
        filter - filter which to invert
        Returns:
        a RowFilter which matches rows not matched by the given filter
      • apply

        public static Iterable<Row> apply​(RowFilter rowFilter,
                                          Iterable<? extends Row> iterable)
        Returns an iterable which filters the given iterable based on the given rowFilter.
        Parameters:
        rowFilter - the filter criteria, may be null
        iterable - row iterable to filter
        Returns:
        a filtering iterable (or the given iterable if a null filter was given)