Class ColumnSelector


  • public final class ColumnSelector
    extends Object
    Utility class to select a number of column fields based on field name and type criteria.
    • Constructor Detail

      • ColumnSelector

        public ColumnSelector()
        Create a column selector. By default we select all columns
    • Method Detail

      • addIncludes

        public ColumnSelector addIncludes​(String... includes)
        Adds columns to include. If set, we will only return columns in this list
        Parameters:
        includes - the set of columns to include
        Returns:
        a "this" reference to allow method chaining
      • addIncludes

        public ColumnSelector addIncludes​(Collection<String> includes)
        Adds columns to include. If set, we will only return columns in this list
        Parameters:
        includes - the set of columns to include
        Returns:
        a "this" reference to allow method chaining
      • addExcludes

        public ColumnSelector addExcludes​(String... excludes)
        Adds columns to exclude. If set, we will exclude those columns specified
        Parameters:
        excludes - the set of columns to exclude
        Returns:
        a "this" reference to allow method chaining
      • addExcludes

        public ColumnSelector addExcludes​(Collection<String> excludes)
        Adds columns to exclude. If set, we will exclude those columns specified
        Parameters:
        excludes - the set of columns to exclude
        Returns:
        a "this" reference to allow method chaining
      • setType

        public ColumnSelector setType​(ScalarTokenType type)
        Sets the type of columns to include. If set, will only return those columns that are assignable to the given type.
        Parameters:
        type - the type of columns to include
        Returns:
        a "this" reference to allow method chaining
      • setMaxDistinctValues

        public ColumnSelector setMaxDistinctValues​(int value)
        Sets the maximum number of distinct values to allow. Columns having more distinct values than that specified or that have an unspecified domain will be filtered. Note that this should only be used by operators that have already discovered domain information since, in general, domain information will not be available.
        Parameters:
        value - the max distinct values
      • filter

        public RecordTokenType filter​(RecordTokenType type)
        Returns a type consisting of a subset of the given type that matches this column selector's criteria. The set of fields returned is as follows
        1. If includes are specified, include only those specified
        2. If excludes are specified, exclude those specified
        3. If type is specified, include only those columns matching the given type
        Parameters:
        type - the input type
        Returns:
        a subset of the input type that matches this column selector's criteria
      • filterNames

        public String[] filterNames​(RecordTokenType type)
        Returns the names of the fields of given type that match this column selector's criteria. The set of fields returned is as follows
        1. If includes are specified, include only those specified
        2. If excludes are specified, exclude those specified
        3. If type is specified, include only those columns matching the given type
        Parameters:
        type - the input type
        Returns:
        a subset of the names of the fields of given type type that match this column selector's criteria