You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2016/06/23 11:24:06 UTC
svn commit: r1749865 - in /tomcat/trunk/java/javax: el/ servlet/jsp/el/
Author: markt
Date: Thu Jun 23 11:24:06 2016
New Revision: 1749865
URL: http://svn.apache.org/viewvc?rev=1749865&view=rev
Log:
Use Objects.requireNonNull() to simplify code
Modified:
tomcat/trunk/java/javax/el/ArrayELResolver.java
tomcat/trunk/java/javax/el/BeanELResolver.java
tomcat/trunk/java/javax/el/BeanNameELResolver.java
tomcat/trunk/java/javax/el/CompositeELResolver.java
tomcat/trunk/java/javax/el/ELContext.java
tomcat/trunk/java/javax/el/LambdaExpression.java
tomcat/trunk/java/javax/el/ListELResolver.java
tomcat/trunk/java/javax/el/MapELResolver.java
tomcat/trunk/java/javax/el/ResourceBundleELResolver.java
tomcat/trunk/java/javax/el/StaticFieldELResolver.java
tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java
tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
Modified: tomcat/trunk/java/javax/el/ArrayELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ArrayELResolver.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/ArrayELResolver.java (original)
+++ tomcat/trunk/java/javax/el/ArrayELResolver.java Thu Jun 23 11:24:06 2016
@@ -20,6 +20,7 @@ package javax.el;
import java.beans.FeatureDescriptor;
import java.lang.reflect.Array;
import java.util.Iterator;
+import java.util.Objects;
public class ArrayELResolver extends ELResolver {
@@ -35,9 +36,7 @@ public class ArrayELResolver extends ELR
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base != null && base.getClass().isArray()) {
context.setPropertyResolved(base, property);
@@ -55,9 +54,7 @@ public class ArrayELResolver extends ELR
@Override
public Object getValue(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base != null && base.getClass().isArray()) {
context.setPropertyResolved(base, property);
@@ -74,9 +71,7 @@ public class ArrayELResolver extends ELR
@Override
public void setValue(ELContext context, Object base, Object property,
Object value) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base != null && base.getClass().isArray()) {
context.setPropertyResolved(base, property);
@@ -100,9 +95,7 @@ public class ArrayELResolver extends ELR
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base != null && base.getClass().isArray()) {
context.setPropertyResolved(base, property);
Modified: tomcat/trunk/java/javax/el/BeanELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/BeanELResolver.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/BeanELResolver.java (original)
+++ tomcat/trunk/java/javax/el/BeanELResolver.java Thu Jun 23 11:24:06 2016
@@ -30,6 +30,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Objects;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
@@ -71,9 +72,7 @@ public class BeanELResolver extends ELRe
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null || property == null) {
return null;
}
@@ -84,9 +83,7 @@ public class BeanELResolver extends ELRe
@Override
public Object getValue(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null || property == null) {
return null;
}
@@ -108,9 +105,7 @@ public class BeanELResolver extends ELRe
@Override
public void setValue(ELContext context, Object base, Object property,
Object value) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null || property == null) {
return;
}
@@ -141,9 +136,7 @@ public class BeanELResolver extends ELRe
@Override
public Object invoke(ELContext context, Object base, Object method,
Class<?>[] paramTypes, Object[] params) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null || method == null) {
return null;
}
@@ -177,9 +170,7 @@ public class BeanELResolver extends ELRe
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null || property == null) {
return false;
}
Modified: tomcat/trunk/java/javax/el/BeanNameELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/BeanNameELResolver.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/BeanNameELResolver.java (original)
+++ tomcat/trunk/java/javax/el/BeanNameELResolver.java Thu Jun 23 11:24:06 2016
@@ -18,6 +18,7 @@ package javax.el;
import java.beans.FeatureDescriptor;
import java.util.Iterator;
+import java.util.Objects;
/**
* @since EL 3.0
@@ -32,10 +33,7 @@ public class BeanNameELResolver extends
@Override
public Object getValue(ELContext context, Object base, Object property) {
-
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base != null || !(property instanceof String)) {
return null;
}
@@ -59,10 +57,7 @@ public class BeanNameELResolver extends
@Override
public void setValue(ELContext context, Object base, Object property,
Object value) {
-
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base != null || !(property instanceof String)) {
return;
}
@@ -100,10 +95,7 @@ public class BeanNameELResolver extends
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
-
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base != null || !(property instanceof String)) {
return null;
}
@@ -126,10 +118,7 @@ public class BeanNameELResolver extends
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
-
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base != null || !(property instanceof String)) {
// Return value undefined
return false;
Modified: tomcat/trunk/java/javax/el/CompositeELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/CompositeELResolver.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/CompositeELResolver.java (original)
+++ tomcat/trunk/java/javax/el/CompositeELResolver.java Thu Jun 23 11:24:06 2016
@@ -19,6 +19,7 @@ package javax.el;
import java.beans.FeatureDescriptor;
import java.util.Iterator;
import java.util.NoSuchElementException;
+import java.util.Objects;
public class CompositeELResolver extends ELResolver {
@@ -43,9 +44,7 @@ public class CompositeELResolver extends
}
public void add(ELResolver elResolver) {
- if (elResolver == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(elResolver);
if (this.size >= this.resolvers.length) {
ELResolver[] nr = new ELResolver[this.size * 2];
Modified: tomcat/trunk/java/javax/el/ELContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ELContext.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/ELContext.java (original)
+++ tomcat/trunk/java/javax/el/ELContext.java Thu Jun 23 11:24:06 2016
@@ -23,6 +23,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
public abstract class ELContext {
@@ -75,9 +76,8 @@ public abstract class ELContext {
*/
public void putContext(@SuppressWarnings("rawtypes") Class key,
Object contextObject) {
- if (key == null || contextObject == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(key);
+ Objects.requireNonNull(contextObject);
if (this.map == null) {
this.map = new HashMap<>();
@@ -98,9 +98,7 @@ public abstract class ELContext {
* If the supplied key is <code>null</code>
*/
public Object getContext(@SuppressWarnings("rawtypes") Class key) {
- if (key == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(key);
if (this.map == null) {
return null;
}
Modified: tomcat/trunk/java/javax/el/LambdaExpression.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/LambdaExpression.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/LambdaExpression.java (original)
+++ tomcat/trunk/java/javax/el/LambdaExpression.java Thu Jun 23 11:24:06 2016
@@ -19,6 +19,7 @@ package javax.el;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
public class LambdaExpression {
@@ -42,9 +43,7 @@ public class LambdaExpression {
public Object invoke(ELContext context, Object... args)
throws ELException {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
int formalParamCount = 0;
if (formalParameters != null) {
Modified: tomcat/trunk/java/javax/el/ListELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ListELResolver.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/ListELResolver.java (original)
+++ tomcat/trunk/java/javax/el/ListELResolver.java Thu Jun 23 11:24:06 2016
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
public class ListELResolver extends ELResolver {
@@ -40,9 +41,7 @@ public class ListELResolver extends ELRe
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof List<?>) {
context.setPropertyResolved(base, property);
@@ -60,9 +59,7 @@ public class ListELResolver extends ELRe
@Override
public Object getValue(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof List<?>) {
context.setPropertyResolved(base, property);
@@ -80,9 +77,7 @@ public class ListELResolver extends ELRe
@Override
public void setValue(ELContext context, Object base, Object property,
Object value) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof List<?>) {
context.setPropertyResolved(base, property);
@@ -107,9 +102,7 @@ public class ListELResolver extends ELRe
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof List<?>) {
context.setPropertyResolved(base, property);
Modified: tomcat/trunk/java/javax/el/MapELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/MapELResolver.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/MapELResolver.java (original)
+++ tomcat/trunk/java/javax/el/MapELResolver.java Thu Jun 23 11:24:06 2016
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
public class MapELResolver extends ELResolver {
@@ -42,9 +43,7 @@ public class MapELResolver extends ELRes
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof Map<?,?>) {
context.setPropertyResolved(base, property);
@@ -56,9 +55,7 @@ public class MapELResolver extends ELRes
@Override
public Object getValue(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof Map<?,?>) {
context.setPropertyResolved(base, property);
@@ -71,9 +68,7 @@ public class MapELResolver extends ELRes
@Override
public void setValue(ELContext context, Object base, Object property,
Object value) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof Map<?, ?>) {
context.setPropertyResolved(base, property);
@@ -95,9 +90,7 @@ public class MapELResolver extends ELRes
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof Map<?, ?>) {
context.setPropertyResolved(base, property);
Modified: tomcat/trunk/java/javax/el/ResourceBundleELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ResourceBundleELResolver.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/ResourceBundleELResolver.java (original)
+++ tomcat/trunk/java/javax/el/ResourceBundleELResolver.java Thu Jun 23 11:24:06 2016
@@ -23,6 +23,7 @@ import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.MissingResourceException;
+import java.util.Objects;
import java.util.ResourceBundle;
public class ResourceBundleELResolver extends ELResolver {
@@ -33,10 +34,7 @@ public class ResourceBundleELResolver ex
@Override
public Object getValue(ELContext context, Object base, Object property) {
-
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof ResourceBundle) {
context.setPropertyResolved(base, property);
@@ -56,9 +54,7 @@ public class ResourceBundleELResolver ex
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof ResourceBundle) {
context.setPropertyResolved(base, property);
@@ -70,9 +66,7 @@ public class ResourceBundleELResolver ex
@Override
public void setValue(ELContext context, Object base, Object property,
Object value) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof ResourceBundle) {
context.setPropertyResolved(base, property);
@@ -83,9 +77,7 @@ public class ResourceBundleELResolver ex
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof ResourceBundle) {
context.setPropertyResolved(base, property);
Modified: tomcat/trunk/java/javax/el/StaticFieldELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/StaticFieldELResolver.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/StaticFieldELResolver.java (original)
+++ tomcat/trunk/java/javax/el/StaticFieldELResolver.java Thu Jun 23 11:24:06 2016
@@ -23,6 +23,7 @@ import java.lang.reflect.InvocationTarge
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Iterator;
+import java.util.Objects;
/**
* @since EL 3.0
@@ -31,10 +32,7 @@ public class StaticFieldELResolver exten
@Override
public Object getValue(ELContext context, Object base, Object property) {
-
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof ELClass && property instanceof String) {
context.setPropertyResolved(base, property);
@@ -68,10 +66,7 @@ public class StaticFieldELResolver exten
@Override
public void setValue(ELContext context, Object base, Object property,
Object value) {
-
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof ELClass && property instanceof String) {
Class<?> clazz = ((ELClass) base).getKlass();
@@ -87,10 +82,7 @@ public class StaticFieldELResolver exten
@Override
public Object invoke(ELContext context, Object base, Object method,
Class<?>[] paramTypes, Object[] params) {
-
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof ELClass && method instanceof String) {
context.setPropertyResolved(base, method);
@@ -151,9 +143,7 @@ public class StaticFieldELResolver exten
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof ELClass && property instanceof String) {
context.setPropertyResolved(base, property);
@@ -186,9 +176,7 @@ public class StaticFieldELResolver exten
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base instanceof ELClass && property instanceof String) {
context.setPropertyResolved(base, property);
Modified: tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java (original)
+++ tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java Thu Jun 23 11:24:06 2016
@@ -26,6 +26,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.Vector;
@@ -77,9 +78,7 @@ public class ImplicitObjectELResolver ex
@Override
public Object getValue(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null && property != null) {
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
@@ -120,9 +119,7 @@ public class ImplicitObjectELResolver ex
@Override
@SuppressWarnings({ "unchecked", "rawtypes" }) // TCK signature test fails with generics
public Class getType(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null && property != null) {
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
@@ -136,9 +133,7 @@ public class ImplicitObjectELResolver ex
@Override
public void setValue(ELContext context, Object base, Object property,
Object value) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null && property != null) {
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
@@ -151,9 +146,7 @@ public class ImplicitObjectELResolver ex
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null && property != null) {
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
@@ -597,9 +590,7 @@ public class ImplicitObjectELResolver ex
@Override
public final V put(String key, V value) {
- if (key == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(key);
if (value == null) {
this.removeAttribute(key);
} else {
@@ -610,13 +601,9 @@ public class ImplicitObjectELResolver ex
@Override
public final V remove(Object key) {
- if (key == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(key);
this.removeAttribute((String) key);
return null;
}
-
}
-
}
Modified: tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java?rev=1749865&r1=1749864&r2=1749865&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java (original)
+++ tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java Thu Jun 23 11:24:06 2016
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
import javax.el.ELClass;
import javax.el.ELContext;
@@ -51,9 +52,7 @@ public class ScopedAttributeELResolver e
@Override
public Object getValue(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
Object result = null;
@@ -112,9 +111,7 @@ public class ScopedAttributeELResolver e
@Override
public Class<Object> getType(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null) {
context.setPropertyResolved(base, property);
@@ -126,9 +123,7 @@ public class ScopedAttributeELResolver e
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null) {
context.setPropertyResolved(base, property);
@@ -147,9 +142,7 @@ public class ScopedAttributeELResolver e
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
- if (context == null) {
- throw new NullPointerException();
- }
+ Objects.requireNonNull(context);
if (base == null) {
context.setPropertyResolved(base, property);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org