public static TagVFilter getFilter(final String tagk, final String filter) {
    if (tagk == null || tagk.isEmpty()) {
      throw new IllegalArgumentException("Tagk cannot be null or empty");
    }
    if (filter == null || filter.isEmpty()) {
      throw new IllegalArgumentException("Filter cannot be null or empty");
    }
    if (filter.length() == 1 && filter.charAt(0) == '*') {
      return null; // group by filter
    }
    
    final int paren = filter.indexOf('(');
    if (paren > -1) {
      final String prefix = filter.substring(0, paren).toLowerCase();
      return new Builder().setTagk(tagk)
                          .setFilter(stripParentheses(filter))
                          .setType(prefix)
                          .build();
    } else if (filter.contains("*")) {
      // a shortcut for wildcards since we don't allow asterisks to be stored
      // in strings at this time.
      return new TagVWildcardFilter(tagk, filter, true);
    } else {
      return null; // likely a literal or unknown
    }
  }
public static TagVFilter getFilter ( final String tagk , final String filter ) { if ( tagk == null || tagk . isEmpty ( ) ) { throw new IllegalArgumentException ( "Tagk cannot be null or empty" ) ; } if ( filter == null || filter . isEmpty ( ) ) { throw new IllegalArgumentException ( "Filter cannot be null or empty" ) ; } if ( filter . length ( ) == 1 && filter . charAt ( 0 ) == '*' ) { return null ; } final int paren = filter . indexOf ( '(' ) ; if ( paren > - 1 ) { final String prefix = filter . substring ( 0 , paren ) . toLowerCase ( ) ; return new Builder ( ) . setTagk ( tagk ) . setFilter ( stripParentheses ( filter ) ) . setType ( prefix ) . build ( ) ; } else if ( filter . contains ( "*" ) ) { return new TagVWildcardFilter ( tagk , filter , true ) ; } else { return null ; } }
Parses the tag value and determines if it's a group by, a literal or a filter.
@param tagk The tag key associated with this value
@param filter The tag value, possibly a filter
@return Null if the value was a group by or a literal, a valid filter object
if it looked to be a filter.
@throws IllegalArgumentException if the tag key or filter was null, empty
or if the filter was malformed, e.g. a bad regular expression.