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 } }
Parses the tag value and determines if it s a group by a literal or a filter .