From 7eff3c86ec73c7963c260ad1cdcab4cd01d5ea9c Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Fri, 30 Dec 2022 15:20:36 +0100 Subject: [PATCH] Code cleanup (rename e->ex in catch; better type for #withUpgradeStep) --- .../com/songoda/core/configuration/ConfigEntry.java | 2 +- .../configuration/songoda/SongodaYamlConfig.java | 12 ++++++------ .../core/configuration/yaml/YamlConfigEntry.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Core/src/main/java/com/songoda/core/configuration/ConfigEntry.java b/Core/src/main/java/com/songoda/core/configuration/ConfigEntry.java index 52cc914f..9e4e8fb6 100644 --- a/Core/src/main/java/com/songoda/core/configuration/ConfigEntry.java +++ b/Core/src/main/java/com/songoda/core/configuration/ConfigEntry.java @@ -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 valueConverter); + ConfigEntry withUpgradeStep(int version, @Nullable String keyInGivenVersion, @Nullable Function<@Nullable Object, @Nullable Object> valueConverter); default @Nullable String getString() { return getStringOr(null); diff --git a/Core/src/main/java/com/songoda/core/configuration/songoda/SongodaYamlConfig.java b/Core/src/main/java/com/songoda/core/configuration/songoda/SongodaYamlConfig.java index 78287078..40cca8bb 100644 --- a/Core/src/main/java/com/songoda/core/configuration/songoda/SongodaYamlConfig.java +++ b/Core/src/main/java/com/songoda/core/configuration/songoda/SongodaYamlConfig.java @@ -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); } } diff --git a/Core/src/main/java/com/songoda/core/configuration/yaml/YamlConfigEntry.java b/Core/src/main/java/com/songoda/core/configuration/yaml/YamlConfigEntry.java index dc075188..d29da1a9 100644 --- a/Core/src/main/java/com/songoda/core/configuration/yaml/YamlConfigEntry.java +++ b/Core/src/main/java/com/songoda/core/configuration/yaml/YamlConfigEntry.java @@ -51,7 +51,7 @@ public class YamlConfigEntry implements WriteableConfigEntry { } @Override - public ConfigEntry withUpgradeStep(int version, @Nullable String keyInGivenVersion, @Nullable Function 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"); }