@ Nonnull public String getTokenName ( final int pTokenId ) { final List < String > searchClasses = Arrays . asList ( "com.puppycrawl.tools.checkstyle.utils.TokenUtil" , "com.puppycrawl.tools.checkstyle.utils.TokenUtils" , TokenTypes . class . getName ( ) , "com.puppycrawl.tools.checkstyle.Utils" ) ; Method getTokenName = null ; for ( final String className : searchClasses ) { try { final Class < ? > utilsClass = Class . forName ( className ) ; getTokenName = utilsClass . getMethod ( "getTokenName" , int . class ) ; break ; } catch ( ClassNotFoundException | NoSuchMethodException e ) { // ignore } } if ( getTokenName == null ) { throw new UnsupportedOperationException ( "getTokenName() - method not found" ) ; } String result = null ; try { result = ( String ) getTokenName . invoke ( null , pTokenId ) ; } catch ( IllegalAccessException | InvocationTargetException e ) { throw new UnsupportedOperationException ( getTokenName . getDeclaringClass ( ) . getName ( ) + ".getTokenName()" , e ) ; } return result ; }
Returns the name of a token for a given ID .