class ProfileUtil {

    public static Profile findProfile(String profileArg, File resourceDir) throws IOException {
        try {
            String profile = profileArg == null ? DEFAULT_PROFILE : profileArg;
            Profile profileFound = lookup(profile, resourceDir);
            if (profileFound != null) {
                if(profileFound.getParentProfile() != null) {
                    profileFound = inheritFromParentProfile(profileFound, resourceDir);
                    log.info(profileFound + " inheriting resources from " + profileFound.getParentProfile());
                }
                return profileFound;
            } else {
                throw new IllegalArgumentException("No profile '" + profile + "' defined");
            }
        } catch (IOException e) {
            throw new IOException("Error while looking up profile " + profileArg + ": " + e.getMessage(),e);
        }
    }

    private  ProfileUtil();

}