@ RestrictTo ( RestrictTo . Scope . LIBRARY ) public boolean fullyResolvesTo ( String key , int depth ) { if ( depth >= keys . size ( ) ) { return false ; } boolean isLastDepth = depth == keys . size ( ) - 1 ; String keyAtDepth = keys . get ( depth ) ; boolean isGlobstar = keyAtDepth . equals ( "**" ) ; if ( ! isGlobstar ) { boolean matches = keyAtDepth . equals ( key ) || keyAtDepth . equals ( "*" ) ; return ( isLastDepth || ( depth == keys . size ( ) - 2 && endsWithGlobstar ( ) ) ) && matches ; } boolean isGlobstarButNextKeyMatches = ! isLastDepth && keys . get ( depth + 1 ) . equals ( key ) ; if ( isGlobstarButNextKeyMatches ) { return depth == keys . size ( ) - 2 || ( depth == keys . size ( ) - 3 && endsWithGlobstar ( ) ) ; } if ( isLastDepth ) { return true ; } if ( depth + 1 < keys . size ( ) - 1 ) { // We are a globstar but there is more than 1 key after the globstar we we can't fully match. return false ; } // Return whether the next key (which we now know is the last one) is the same as the current // key. return keys . get ( depth + 1 ) . equals ( key ) ; }
Returns whether the key at specified depth is fully specific enough to match the full set of keys in this keypath .