From: David ‘Bombe’ Roden Date: Mon, 18 Oct 2010 19:45:28 +0000 (+0200) Subject: Throw exceptions if attributes are not set. X-Git-Tag: 0.1-RC1~217 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8cb84027861a382525fb206a6aa320a5796115a1;p=Sone.git Throw exceptions if attributes are not set. --- diff --git a/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java b/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java index e942b19..97b463c 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java +++ b/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java @@ -17,6 +17,7 @@ package net.pterodactylus.sone.freenet; +import net.pterodactylus.util.config.AttributeNotFoundException; import net.pterodactylus.util.config.Configuration; import net.pterodactylus.util.config.ConfigurationException; import net.pterodactylus.util.config.ExtendedConfigurationBackend; @@ -47,6 +48,9 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac */ @Override public String getValue(String attribute) throws ConfigurationException { + if (!pluginStore.strings.containsKey(attribute)) { + throw new AttributeNotFoundException(attribute); + } return pluginStore.strings.get(attribute); } @@ -63,6 +67,9 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac */ @Override public Boolean getBooleanValue(String attribute) throws ConfigurationException { + if (!pluginStore.booleans.containsKey(attribute)) { + throw new AttributeNotFoundException(attribute); + } return pluginStore.booleans.get(attribute); } @@ -79,6 +86,9 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac */ @Override public Double getDoubleValue(String attribute) throws ConfigurationException { + if (!pluginStore.strings.containsKey(attribute)) { + throw new AttributeNotFoundException(attribute); + } String stringValue = pluginStore.strings.get(attribute); if (stringValue == null) { return null; @@ -103,6 +113,9 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac */ @Override public Integer getIntegerValue(String attribute) throws ConfigurationException { + if (!pluginStore.integers.containsKey(attribute)) { + throw new AttributeNotFoundException(attribute); + } return pluginStore.integers.get(attribute); } @@ -119,6 +132,9 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac */ @Override public Long getLongValue(String attribute) throws ConfigurationException { + if (!pluginStore.longs.containsKey(attribute)) { + throw new AttributeNotFoundException(attribute); + } return pluginStore.longs.get(attribute); }