private String findMainFileFromBackupSuffix(File searchDir, String backupType) {

        final String suffix = "." + backupType + ".xml";
        File[] files = null;
        if (searchDir.exists() && searchDir.isDirectory()) {
            files = searchDir.listFiles(new FilenameFilter() {
                @Override
                public boolean accept(File dir, String name) {
                    return name.endsWith(suffix);
                }

            });
        }

        if (files == null || files.length == 0) {
            throw ControllerLogger.ROOT_LOGGER.configurationFileNotFound(suffix, searchDir);
        } else if (files.length > 1) {
            throw ControllerLogger.ROOT_LOGGER.ambiguousConfigurationFiles(backupType, searchDir, suffix);
        }

        String matchName = files[0].getName();
        if (matchName.equals(suffix)) {
            throw ControllerLogger.ROOT_LOGGER.configurationFileNameNotAllowed(backupType);
        }
        String prefix = matchName.substring(0, matchName.length() - suffix.length());
        return prefix + ".xml";
    }
private String findMainFileFromBackupSuffix ( File searchDir , String backupType ) { final String suffix = "." + backupType + ".xml" ; File [ ] files = null ; if ( searchDir . exists ( ) && searchDir . isDirectory ( ) ) { files = searchDir . listFiles ( new FilenameFilter ( ) { @ Override public boolean accept ( File dir , String name ) { return name . endsWith ( suffix ) ; } } ) ; } if ( files == null || files . length == 0 ) { throw ControllerLogger . ROOT_LOGGER . configurationFileNotFound ( suffix , searchDir ) ; } else if ( files . length > 1 ) { throw ControllerLogger . ROOT_LOGGER . ambiguousConfigurationFiles ( backupType , searchDir , suffix ) ; } String matchName = files [ 0 ] . getName ( ) ; if ( matchName . equals ( suffix ) ) { throw ControllerLogger . ROOT_LOGGER . configurationFileNameNotAllowed ( backupType ) ; } String prefix = matchName . substring ( 0 , matchName . length ( ) - suffix . length ( ) ) ; return prefix + ".xml" ; }
Finds a single file in {@code searchDir} whose name ends with "{@code .backupType.xml}"
and returns its name with {@code .backupType} removed.

@param searchDir  the directory to search
@param backupType the backup type; {@link #LAST}, {@link #BOOT}, {@link #INITIAL} or {@code v\d+}
@return the single file that meets the criteria. Will not return {@code null}
@throws IllegalStateException    if no files meet the criteria or more than one does
@throws IllegalArgumentException if they file that meets the criteria's full name is "{@code backupType.xml}"