diff options
author | Claude Brisson <cbrisson@apache.org> | 2017-01-26 02:49:58 +0000 |
---|---|---|
committer | Claude Brisson <cbrisson@apache.org> | 2017-01-26 02:49:58 +0000 |
commit | 1a8fd6a27e102bd0c1b3750f22a6ef8e2e3a3c16 (patch) | |
tree | 41ce747c7bae8d93b557bb3e42fbbf47e19d7141 /velocity-engine-core/src/main/java/org/apache/velocity/util | |
parent | ef2d9b1132c38dea1a1900ba40fcad580628a81b (diff) | |
download | apache-velocity-engine-1a8fd6a27e102bd0c1b3750f22a6ef8e2e3a3c16.tar.gz |
[engine] use commons.lang3.Validate whenever appropriate
git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@1780316 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'velocity-engine-core/src/main/java/org/apache/velocity/util')
3 files changed, 11 insertions, 33 deletions
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java index 0c4bf964..46280057 100644 --- a/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java +++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java @@ -1002,7 +1002,7 @@ public class ExtProperties extends Hashtable<String,Object> { String pvalue = token.substring(equalSign + 1).trim(); props.put(pkey, pvalue); } else { - throw new IllegalArgumentException('\'' + token + "' does not contain " + "an equals sign"); + throw new IllegalArgumentException('\'' + token + "' does not contain an equals sign"); } } return props; diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectorBase.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectorBase.java index 827f076e..e98ec35b 100644 --- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectorBase.java +++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectorBase.java @@ -19,6 +19,7 @@ package org.apache.velocity.util.introspection; * under the License. */ +import org.apache.commons.lang3.Validate; import org.slf4j.Logger; import java.lang.reflect.Field; @@ -84,31 +85,21 @@ public abstract class IntrospectorBase * the parameters * * @return The desired Method object. - * @throws IllegalArgumentException When the parameters passed in can not be used for introspection. + * @throws NullPointerException When the parameters passed in can not be used for introspection because null. * @throws MethodMap.AmbiguousException When the method map contains more than one match for the requested signature. */ public Method getMethod(final Class c, final String name, final Object[] params) - throws IllegalArgumentException,MethodMap.AmbiguousException + throws MethodMap.AmbiguousException { - if (c == null) - { - throw new IllegalArgumentException ("class object is null!"); - } - - if (params == null) - { - throw new IllegalArgumentException("params object is null!"); - } - IntrospectorCache ic = getIntrospectorCache(); - ClassMap classMap = ic.get(c); + ClassMap classMap = ic.get(Validate.notNull(c, "class object is null!")); if (classMap == null) { classMap = ic.put(c); } - return classMap.findMethod(name, params); + return classMap.findMethod(name, Validate.notNull(params, "params object is null!")); } /** @@ -123,14 +114,9 @@ public abstract class IntrospectorBase public Field getField(final Class c, final String name) throws IllegalArgumentException { - if (c == null) - { - throw new IllegalArgumentException("class object is null!"); - } - IntrospectorCache ic = getIntrospectorCache(); - ClassFieldMap classFieldMap = ic.getFieldMap(c); + ClassFieldMap classFieldMap = ic.getFieldMap(Validate.notNull(c, "class object is null!")); if (classFieldMap == null) { ic.put(c); diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectorCache.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectorCache.java index 6d066bf3..742dcc3b 100644 --- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectorCache.java +++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectorCache.java @@ -19,6 +19,8 @@ package org.apache.velocity.util.introspection; * under the License. */ +import org.apache.commons.lang3.Validate; + import org.slf4j.Logger; import java.util.HashMap; @@ -101,12 +103,7 @@ public final class IntrospectorCache */ public ClassMap get(final Class c) { - if (c == null) - { - throw new IllegalArgumentException("class is null!"); - } - - ClassMap classMap = (ClassMap)classMapCache.get(c); + ClassMap classMap = (ClassMap)classMapCache.get(Validate.notNull(c)); if (classMap == null) { /* @@ -136,12 +133,7 @@ public final class IntrospectorCache */ public ClassFieldMap getFieldMap(final Class c) { - if (c == null) - { - throw new IllegalArgumentException("class is null!"); - } - - ClassFieldMap classFieldMap = (ClassFieldMap)classFieldMapCache.get(c); + ClassFieldMap classFieldMap = (ClassFieldMap)classFieldMapCache.get(Validate.notNull(c)); if (classFieldMap == null) { /* |