Just a minor tweak to the logic to check early for a null

Properties object.
This commit is contained in:
Oliver Burn 2003-02-23 21:53:17 +00:00
parent 03d9719f47
commit c60f4cb6f2
1 changed files with 10 additions and 5 deletions

View File

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