public static String stripSuffixIfPresent ( final String key , final String suffix ) { if ( key . endsWith ( suffix ) ) { return key . substring ( 0 , key . length ( ) - suffix . length ( ) ) ; } return key ; }
Strips the suffix if it exists . This method will leave keys without a suffix unaltered .