@ Override public V get ( Object key ) { // Keys can not be null if ( key == null ) { throw new NullPointerException ( "Key can not be null" ) ; } if ( ! ( key instanceof String ) ) { throw new ClassCastException ( "Only String keys are supported -- got " + key . getClass ( ) ) ; } // Empty keys are stored in the root if ( key . equals ( "" ) ) { if ( root . getRight ( ) == null ) { return null ; } else { return root . getRight ( ) . getValue ( ) ; } } // Find nearest node PatriciaNode < V > nearest = findNearestNode ( ( String ) key ) ; // If the nearest node matches key, we have a match if ( key . equals ( nearest . getKey ( ) ) ) { return nearest . getValue ( ) ; } else { return null ; } }
Get value associated with specified key in this trie