mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 10:35:18 +01:00
Code cleanup (rename e->ex in catch; better type for #withUpgradeStep)
This commit is contained in:
parent
c728c5fcc7
commit
7eff3c86ec
@ -67,7 +67,7 @@ public interface ConfigEntry {
|
||||
* @param valueConverter A function that converts the old version's value to a new one, or null if it didn't change
|
||||
*/
|
||||
@Contract("_, null, null -> fail; _, _, _ -> this")
|
||||
ConfigEntry withUpgradeStep(int version, @Nullable String keyInGivenVersion, @Nullable Function<Object, Object> valueConverter);
|
||||
ConfigEntry withUpgradeStep(int version, @Nullable String keyInGivenVersion, @Nullable Function<@Nullable Object, @Nullable Object> valueConverter);
|
||||
|
||||
default @Nullable String getString() {
|
||||
return getStringOr(null);
|
||||
|
@ -79,8 +79,8 @@ public class SongodaYamlConfig extends YamlConfiguration {
|
||||
this.save();
|
||||
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
this.logger.log(Level.SEVERE, "Failed to load config file: " + this.file.getPath(), e);
|
||||
} catch (IOException ex) {
|
||||
this.logger.log(Level.SEVERE, "Failed to load config file: " + this.file.getPath(), ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -134,8 +134,8 @@ public class SongodaYamlConfig extends YamlConfiguration {
|
||||
try (Reader reader = new FileReader(this.file)) {
|
||||
load(reader);
|
||||
} catch (FileNotFoundException ignore) {
|
||||
} catch (IOException e) {
|
||||
throw new IOException("Unable to load '" + this.file.getPath() + "'", e);
|
||||
} catch (IOException ex) {
|
||||
throw new IOException("Unable to load '" + this.file.getPath() + "'", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,8 +144,8 @@ public class SongodaYamlConfig extends YamlConfiguration {
|
||||
|
||||
try (Writer writer = new FileWriter(this.file)) {
|
||||
super.save(writer);
|
||||
} catch (IOException e) {
|
||||
throw new IOException("Unable to save '" + this.file.getPath() + "'", e);
|
||||
} catch (IOException ex) {
|
||||
throw new IOException("Unable to save '" + this.file.getPath() + "'", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class YamlConfigEntry implements WriteableConfigEntry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigEntry withUpgradeStep(int version, @Nullable String keyInGivenVersion, @Nullable Function<Object, Object> valueConverter) {
|
||||
public ConfigEntry withUpgradeStep(int version, @Nullable String keyInGivenVersion, @Nullable Function<@Nullable Object, @Nullable Object> valueConverter) {
|
||||
if (keyInGivenVersion == null && valueConverter == null) {
|
||||
throw new IllegalArgumentException("You must provide either a key or a value converter");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user