@ Override public C classify ( T classifiable ) { if ( classifiable == null ) { return this . defaultValue ; } @ SuppressWarnings ( "unchecked" ) Class < ? extends T > exceptionClass = ( Class < ? extends T > ) classifiable . getClass ( ) ; if ( this . classified . containsKey ( exceptionClass ) ) { return this . classified . get ( exceptionClass ) ; } // check for subclasses C value = null ; for ( Class < ? > cls = exceptionClass ; ! cls . equals ( Object . class ) && value == null ; cls = cls . getSuperclass ( ) ) { value = this . classified . get ( cls ) ; } // ConcurrentHashMap doesn't allow nulls if ( value != null ) { this . classified . put ( exceptionClass , value ) ; } if ( value == null ) { value = this . defaultValue ; } return value ; }
Return the value from the type map whose key is the class of the given Throwable or its nearest ancestor if a subclass .