question: public static void validate ( String topicString , boolean wildcardAllowed ) throws IllegalStateException , IllegalArgumentException { int topicLen = 0 ; try { topicLen = topicString . getBytes ( "UTF-8" ) . length ; } catch ( UnsupportedEncodingException e ) { throw new IllegalStateException ( e ) ; } if ( topicLen < MIN_TOPIC_LEN || topicLen > MAX_TOPIC_LEN ) { throw new IllegalArgumentException ( String . format ( "Invalid topic length, should be in range[%d, %d]!" , new Object [ ] { new Integer ( MIN_TOPIC_LEN ) , new Integer ( MAX_TOPIC_LEN ) } ) ) ; } if ( wildcardAllowed ) { if ( Strings . equalsAny ( topicString , new String [ ] { MULTI_LEVEL_WILDCARD , SINGLE_LEVEL_WILDCARD } ) ) { return ; } if ( Strings . countMatches ( topicString , MULTI_LEVEL_WILDCARD ) > 1 || ( topicString . contains ( MULTI_LEVEL_WILDCARD ) && ! topicString . endsWith ( MULTI_LEVEL_WILDCARD_PATTERN ) ) ) { throw new IllegalArgumentException ( "Invalid usage of multi-level wildcard in topic string: " + topicString ) ; } validateSingleLevelWildcard ( topicString ) ; return ; } if ( Strings . containsAny ( topicString , TOPIC_WILDCARDS ) ) { throw new IllegalArgumentException ( "The topic name MUST NOT contain any wildcard characters (#+)" ) ; } }
target:  Validate the topic name or topic filter