Code cleanup (rename e->ex in catch; better type for #withUpgradeStep)

This commit is contained in:
Christian Koop 2022-12-30 15:20:36 +01:00
parent c728c5fcc7
commit 7eff3c86ec
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
3 changed files with 8 additions and 8 deletions

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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");
}