class Migrator {

    public void migrate(ConfigurationProvider provider, PreferencesRegistry registry)
    {
        Preferences newPreferences = registry.getPreferences(MantleConstants.USER_DATE_FORMAT_CONFIG_FILE_TOPIC);

        boolean alreadyMigrated = newPreferences.getBoolean(ourMigratedKey, false);

        if (!alreadyMigrated)
        {
            Preferences preferences = registry.getPreferences("DateFormatConfiguration");
            DateFormatsConfig oldConfig = preferences.getJAXBObject(DateFormatsConfig.class,
                    MantleConstants.USER_DATE_FORMAT_CONFIG_FILE_KEY, null);

            DateFormatsConfig newConfig = provider.getDateFormats();

            List<DateFormat> formatsToAdd = New.list();

            if (oldConfig != null)
            {
                Map<String, DateFormat> formats = mapFormats(newConfig);

                for (DateFormat format : oldConfig.getFormats())
                {
                    if (!formats.containsKey(format.getSdf()))
                    {
                        boolean isValid = isFormatValid(format);
                        if (isValid)
                        {
                            formatsToAdd.add(format);
                        }
                    }
                }

                if (!formatsToAdd.isEmpty())
                {
                    provider.saveFormats(formatsToAdd);
                }
            }

            newPreferences.putBoolean(ourMigratedKey, true, this);
        }
    }

}