package de.steamwar.bausystem.configplayer;

import yapion.hierarchy.types.YAPIONObject;

/**
 * A new {@link ConfigConverter} should be written when you remove anything
 * from the Config or modify any mayor part. When you move anything from
 * any key to any other key you should write a new {@link ConfigConverter}.
 * For adding any new key you should be able to get the default without
 * having it in the Config. Anything you need to change you should also
 * change the {@link ConfigCreator} accordingly, to produce the new Config.
 */
public interface ConfigConverter {

    /**
     * This describes the version this Converter can convert from. The version
     * it should convert to is the version 1 above this number. But this is not
     * a necessity. In the config Object as parameter given in {@link #update(YAPIONObject)}
     * you should update the <b>@version</b> variable in the root object to the
     * new version this converter produced.
     *
     * @return the version number
     */
    int version();

    /**
     * This method should update everything needed to go from a lower config
     * version to a higher. It should update the <b>@version</b> variable
     * accordingly. Anything else is up the implementation. If anything goes wrong
     * do not silently exit this method, throw an Exception. The updater Code will
     * deal with it. Never leave the inputted object in a corrupted state.
     *
     * @param config the config object to update
     */
    void update(YAPIONObject config);

}
