forked from SteamWar/SteamWar
48 lines
1.6 KiB
Java
48 lines
1.6 KiB
Java
/*
|
|
* This file is a part of the SteamWar software.
|
|
*
|
|
* Copyright (C) 2025 SteamWar.de-Serverteam
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package de.steamwar.bausystem.config;
|
|
|
|
/**
|
|
* Converts a config of one version into the next version, e.g. ConfigV1 to
|
|
* ConfigV2. The converter for the second newest version converts into the
|
|
* current version. Converters are registered in the {@link ConfigStore}
|
|
* of the config.
|
|
*
|
|
* @param <F> the config version to convert from
|
|
* @param <T> the config version to convert to
|
|
*/
|
|
public interface ConfigConverter<F extends VersionedConfig, T extends VersionedConfig> {
|
|
|
|
/**
|
|
* @return the version this converter converts from
|
|
*/
|
|
int version();
|
|
|
|
/**
|
|
* Converts the config to the next version. If anything goes wrong do not
|
|
* silently exit this method, throw an Exception. The {@link ConfigStore}
|
|
* will deal with it.
|
|
*
|
|
* @param config the config to convert
|
|
* @return the converted config
|
|
*/
|
|
T convert(F config);
|
|
}
|