From c60f4cb6f208cbc3e09b350ad3dcd1054012fac6 Mon Sep 17 00:00:00 2001 From: Oliver Burn Date: Sun, 23 Feb 2003 21:53:17 +0000 Subject: [PATCH] Just a minor tweak to the logic to check early for a null Properties object. --- .../tools/checkstyle/PropertiesExpander.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/PropertiesExpander.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/PropertiesExpander.java index 9a3f958f5..a32023654 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/PropertiesExpander.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/PropertiesExpander.java @@ -28,18 +28,23 @@ import com.puppycrawl.tools.checkstyle.api.CheckstyleException; * * @author lkuehne */ -public final class PropertiesExpander implements PropertyResolver +public final class PropertiesExpander + implements PropertyResolver { /** the underlying Properties object. */ - private Properties mProperties = null; + private final Properties mProperties; /** * Creates a new PropertiesExpander. * @param aProperties the underlying properties to use for * property resolution. + * @throws IllegalArgumentException indicates null was passed */ public PropertiesExpander(Properties aProperties) { + if (aProperties == null) { + throw new IllegalArgumentException("cannot pass null"); + } mProperties = aProperties; } @@ -50,9 +55,9 @@ public final class PropertiesExpander implements PropertyResolver public String resolve(String aPropertyName) throws CheckstyleException { - if (mProperties == null || !mProperties.containsKey(aPropertyName)) { - throw new CheckstyleException("Property ${" - + aPropertyName + "} has not been set"); + if (!mProperties.containsKey(aPropertyName)) { + throw new CheckstyleException( + "Property ${" + aPropertyName + "} has not been set"); } return mProperties.getProperty(aPropertyName);