class FormMetadataMigrator {

    @SuppressLint("ApplySharedPref")
    public static void migrate(SharedPreferences sharedPreferences) {
        boolean migrationAlreadyDone = sharedPreferences.getBoolean(KEY_METADATA_MIGRATED, false);
        Timber.i("migrate called, %s",
                migrationAlreadyDone ? "migration already done" : "will migrate");

        if (!migrationAlreadyDone) {
            SharedPreferences.Editor editor = sharedPreferences.edit();

            for (String[] pair : SOURCE_TARGET_VALUE_PAIRS) {
                String migratingValue = sharedPreferences.getString(pair[0], "").trim();
                if (!migratingValue.isEmpty()) {
                    Timber.i("Copying %s from %s to %s", migratingValue, pair[0], pair[1]);
                    editor.putString(pair[1], migratingValue);
                }
            }

            // Save that we’ve migrated the values
            editor.putBoolean(KEY_METADATA_MIGRATED, true);
            editor.commit();
        }
    }

    private  FormMetadataMigrator();

}