myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: refactored
Date Mon, 03 Dec 2018 10:46:04 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b961cd  refactored
7b961cd is described below

commit 7b961cd98d8e32c8f6dd4e50deb80b863920f034
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Mon Dec 3 11:45:59 2018 +0100

    refactored
---
 .../myfaces/application/ApplicationImpl.java       | 113 ++++++++-------------
 .../servlet/ServletExternalContextImpl.java        |  14 +--
 .../servlet/ServletExternalContextImplBase.java    |  42 +++-----
 .../org/apache/myfaces/flow/FlowHandlerImpl.java   |  31 +++---
 .../myfaces/renderkit/RenderKitFactoryImpl.java    |   6 +-
 .../myfaces/renderkit/_SharedRendererUtils.java    |   6 +-
 .../main/java/org/apache/myfaces/util/Assert.java  |  12 ++-
 7 files changed, 92 insertions(+), 132 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java b/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
index 1b88944..8adca55 100755
--- a/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
@@ -122,6 +122,7 @@ import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.Scope;
 import org.apache.myfaces.flow.FlowHandlerImpl;
 import org.apache.myfaces.lifecycle.LifecycleImpl;
 import org.apache.myfaces.config.MyfacesConfig;
+import org.apache.myfaces.util.Assert;
 import org.apache.myfaces.util.ClassUtils;
 import org.apache.myfaces.view.facelets.FaceletCompositionContext;
 import org.apache.myfaces.view.facelets.el.ELText;
@@ -409,8 +410,8 @@ public class ApplicationImpl extends Application
             throws FacesException, NullPointerException
     {
 
-        checkNull(facesContext, "facesContext");
-        checkNull(name, "name");
+        Assert.notNull(facesContext, "facesContext");
+        Assert.notNull(name, "name");
 
         final String bundleName = getBundleName(facesContext, name);
 
@@ -488,9 +489,9 @@ public class ApplicationImpl extends Application
          * be returned for any of the afore mentioned annotations. Such inspection is the
province of
          */
 
-        checkNull(componentExpression, "componentExpression");
-        checkNull(facesContext, "facesContext");
-        checkNull(componentType, "componentType");
+        Assert.notNull(componentExpression, "componentExpression");
+        Assert.notNull(facesContext, "facesContext");
+        Assert.notNull(componentType, "componentType");
 
         ELContext elContext = facesContext.getELContext();
 
@@ -569,8 +570,8 @@ public class ApplicationImpl extends Application
     public void publishEvent(FacesContext facesContext, Class<? extends SystemEvent>
systemEventClass,
                              Class<?> sourceBaseType, Object source)
     {
-        checkNull(systemEventClass, "systemEventClass");
-        checkNull(source, "source");
+        Assert.notNull(systemEventClass, "systemEventClass");
+        Assert.notNull(source, "source");
         
         //Call events only if event processing is enabled.
         if (!facesContext.isProcessingEvents())
@@ -651,7 +652,7 @@ public class ApplicationImpl extends Application
     @Override
     public final void setActionListener(final ActionListener actionListener)
     {
-        checkNull(actionListener, "actionListener");
+        Assert.notNull(actionListener, "actionListener");
 
         _actionListener = actionListener;
         if (log.isLoggable(Level.FINEST))
@@ -693,7 +694,7 @@ public class ApplicationImpl extends Application
     @Override
     public final void setDefaultLocale(final Locale locale)
     {
-        checkNull(locale, "locale");
+        Assert.notNull(locale, "locale");
 
         _defaultLocale = locale;
         if (log.isLoggable(Level.FINEST))
@@ -711,7 +712,7 @@ public class ApplicationImpl extends Application
     @Override
     public final void setMessageBundle(final String messageBundle)
     {
-        checkNull(messageBundle, "messageBundle");
+        Assert.notNull(messageBundle, "messageBundle");
 
         _messageBundle = messageBundle;
         if (log.isLoggable(Level.FINEST))
@@ -729,7 +730,7 @@ public class ApplicationImpl extends Application
     @Override
     public final void setNavigationHandler(final NavigationHandler navigationHandler)
     {
-        checkNull(navigationHandler, "navigationHandler");
+        Assert.notNull(navigationHandler, "navigationHandler");
 
         _navigationHandler = navigationHandler;
         if (log.isLoggable(Level.FINEST))
@@ -846,7 +847,7 @@ public class ApplicationImpl extends Application
     @Override
     public final void setResourceHandler(ResourceHandler resourceHandler)
     {
-        checkNull(resourceHandler, "resourceHandler");
+        Assert.notNull(resourceHandler, "resourceHandler");
 
         if(isFirstRequestProcessed())
         {
@@ -865,7 +866,7 @@ public class ApplicationImpl extends Application
     @Override
     public final void setSupportedLocales(final Collection<Locale> locales)
     {
-        checkNull(locales, "locales");
+        Assert.notNull(locales, "locales");
 
         _supportedLocales = locales;
         if (log.isLoggable(Level.FINEST))
@@ -889,7 +890,7 @@ public class ApplicationImpl extends Application
     @Override
     public final void setViewHandler(final ViewHandler viewHandler)
     {
-        checkNull(viewHandler, "viewHandler");
+        Assert.notNull(viewHandler, "viewHandler");
 
         if(isFirstRequestProcessed())
         {
@@ -913,8 +914,8 @@ public class ApplicationImpl extends Application
     public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass, Class<?>
sourceClass,
                                  SystemEventListener listener)
     {
-        checkNull(systemEventClass, "systemEventClass");
-        checkNull(listener, "listener");
+        Assert.notNull(systemEventClass, "systemEventClass");
+        Assert.notNull(listener, "listener");
 
         SystemListenerEntry systemListenerEntry;
         synchronized (_systemEventListenerClassMap)
@@ -940,8 +941,8 @@ public class ApplicationImpl extends Application
     public void unsubscribeFromEvent(Class<? extends SystemEvent> systemEventClass,
Class<?> sourceClass,
                                      SystemEventListener listener)
     {
-        checkNull(systemEventClass, "systemEventClass");
-        checkNull(listener, "listener");
+        Assert.notNull(systemEventClass, "systemEventClass");
+        Assert.notNull(listener, "listener");
 
         SystemListenerEntry systemListenerEntry = _systemEventListenerClassMap.get(systemEventClass);
         if (systemListenerEntry != null)
@@ -959,10 +960,8 @@ public class ApplicationImpl extends Application
     @Override
     public void addBehavior(String behaviorId, String behaviorClass)
     {
-        checkNull(behaviorId, "behaviorId");
-        checkEmpty(behaviorId, "behaviorId");
-        checkNull(behaviorClass, "behaviorClass");
-        checkEmpty(behaviorClass, "behaviorClass");
+        Assert.notEmpty(behaviorId, "behaviorId");
+        Assert.notEmpty(behaviorClass, "behaviorClass");
 
         try
         {
@@ -990,10 +989,8 @@ public class ApplicationImpl extends Application
     @Override
     public final void addComponent(final String componentType, final String componentClassName)
     {
-        checkNull(componentType, "componentType");
-        checkEmpty(componentType, "componentType");
-        checkNull(componentClassName, "componentClassName");
-        checkEmpty(componentClassName, "componentClassName");
+        Assert.notEmpty(componentType, "componentType");
+        Assert.notEmpty(componentClassName, "componentClassName");
 
         try
         {
@@ -1020,10 +1017,8 @@ public class ApplicationImpl extends Application
     @Override
     public final void addConverter(final String converterId, final String converterClass)
     {
-        checkNull(converterId, "converterId");
-        checkEmpty(converterId, "converterId");
-        checkNull(converterClass, "converterClass");
-        checkEmpty(converterClass, "converterClass");
+        Assert.notEmpty(converterId, "converterId");
+        Assert.notEmpty(converterClass, "converterClass");
 
         try
         {
@@ -1049,9 +1044,8 @@ public class ApplicationImpl extends Application
     @Override
     public final void addConverter(final Class<?> targetClass, final String converterClass)
     {
-        checkNull(targetClass, "targetClass");
-        checkNull(converterClass, "converterClass");
-        checkEmpty(converterClass, "converterClass");
+        Assert.notNull(targetClass, "targetClass");
+        Assert.notEmpty(converterClass, "converterClass");
 
         try
         {
@@ -1079,10 +1073,8 @@ public class ApplicationImpl extends Application
     @Override
     public final void addValidator(final String validatorId, final String validatorClass)
     {
-        checkNull(validatorId, "validatorId");
-        checkEmpty(validatorId, "validatorId");
-        checkNull(validatorClass, "validatorClass");
-        checkEmpty(validatorClass, "validatorClass");
+        Assert.notEmpty(validatorId, "validatorId");
+        Assert.notEmpty(validatorClass, "validatorClass");
 
         try
         {
@@ -1109,8 +1101,7 @@ public class ApplicationImpl extends Application
     @Override
     public Behavior createBehavior(String behaviorId) throws FacesException
     {
-        checkNull(behaviorId, "behaviorId");
-        checkEmpty(behaviorId, "behaviorId");
+        Assert.notEmpty(behaviorId, "behaviorId");
 
         final Class<? extends Behavior> behaviorClass =
                 getObjectFromClassMap(behaviorId, _behaviorClassMap);
@@ -1192,8 +1183,8 @@ public class ApplicationImpl extends Application
     @Override
     public UIComponent createComponent(FacesContext context, Resource componentResource)
     {
-        checkNull(context, "context");
-        checkNull(componentResource, "componentResource");
+        Assert.notNull(context, "context");
+        Assert.notNull(componentResource, "componentResource");
         
         UIComponent component = null;
         Resource resource;
@@ -1369,8 +1360,8 @@ public class ApplicationImpl extends Application
     @Override
     public UIComponent createComponent(FacesContext context, String componentType, String
rendererType)
     {
-        checkNull(context, "context");
-        checkNull(componentType, "componentType");
+        Assert.notNull(context, "context");
+        Assert.notNull(componentType, "componentType");
 
         // Like createComponent(String)
         UIComponent component = createComponent(context, componentType);
@@ -1397,8 +1388,7 @@ public class ApplicationImpl extends Application
     private final UIComponent createComponent(FacesContext facesContext, 
             final String componentType) throws FacesException
     {
-        checkNull(componentType, "componentType");
-        checkEmpty(componentType, "componentType");
+        Assert.notEmpty(componentType, "componentType");
 
         final Class<? extends UIComponent> componentClass =
                 getObjectFromClassMap(componentType, _componentClassMap);
@@ -1424,8 +1414,7 @@ public class ApplicationImpl extends Application
     @Override
     public final UIComponent createComponent(final String componentType) throws FacesException
     {
-        checkNull(componentType, "componentType");
-        checkEmpty(componentType, "componentType");
+        Assert.notEmpty(componentType, "componentType");
 
         final Class<? extends UIComponent> componentClass =
                 getObjectFromClassMap(componentType, _componentClassMap);
@@ -1475,8 +1464,7 @@ public class ApplicationImpl extends Application
     @Override
     public final Converter createConverter(final String converterId)
     {
-        checkNull(converterId, "converterId");
-        checkEmpty(converterId, "converterId");
+        Assert.notEmpty(converterId, "converterId");
 
         final Class<? extends Converter> converterClass =
                 getObjectFromClassMap(converterId, _converterIdToClassMap);
@@ -1538,7 +1526,7 @@ public class ApplicationImpl extends Application
     @Override
     public final Converter createConverter(final Class<?> targetClass)
     {
-        checkNull(targetClass, "targetClass");
+        Assert.notNull(targetClass, "targetClass");
 
         return internalCreateConverter(targetClass);
     }
@@ -1964,8 +1952,7 @@ public class ApplicationImpl extends Application
     @Override
     public final Validator createValidator(final String validatorId) throws FacesException
     {
-        checkNull(validatorId, "validatorId");
-        checkEmpty(validatorId, "validatorId");
+        Assert.notEmpty(validatorId, "validatorId");
 
         Class<? extends Validator> validatorClass =
                 getObjectFromClassMap(validatorId, _validatorClassMap);
@@ -2050,7 +2037,7 @@ public class ApplicationImpl extends Application
     @Override
     public final void setStateManager(final StateManager stateManager)
     {
-        checkNull(stateManager, "stateManager");
+        Assert.notNull(stateManager, "stateManager");
 
         if(isFirstRequestProcessed())
         {
@@ -2064,7 +2051,7 @@ public class ApplicationImpl extends Application
     @Override
     public final void setFlowHandler(FlowHandler flowHandler)
     {
-        checkNull(flowHandler, "flowHandler");
+        Assert.notNull(flowHandler, "flowHandler");
 
         if(isFirstRequestProcessed())
         {
@@ -2080,22 +2067,6 @@ public class ApplicationImpl extends Application
         return _flowHandler;
     }
 
-    private void checkNull(final Object param, final String paramName)
-    {
-        if (param == null)
-        {
-            throw new NullPointerException(paramName + " cannot be null.");
-        }
-    }
-
-    private void checkEmpty(final String param, final String paramName)
-    {
-        if (param.length() == 0)
-        {
-            throw new NullPointerException("String " + paramName + " cannot be empty.");
-        }
-    }
-
     private void _handleAnnotations(FacesContext context, Object inspected, UIComponent component)
     {   
         // determine the ProjectStage setting via the given FacesContext
@@ -2660,7 +2631,7 @@ public class ApplicationImpl extends Application
     @Override
     public final void setSearchExpressionHandler(SearchExpressionHandler searchExpressionHandler)
     {
-        checkNull(searchExpressionHandler, "searchExpressionHandler");
+        Assert.notNull(searchExpressionHandler, "searchExpressionHandler");
 
         if(isFirstRequestProcessed())
         {
diff --git a/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
b/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
index 0e4ed0d..6ffd2ab 100755
--- a/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
@@ -57,6 +57,7 @@ import javax.servlet.http.HttpSession;
 
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
 import org.apache.myfaces.context.flash.FlashImpl;
+import org.apache.myfaces.util.Assert;
 import org.apache.myfaces.util.WebConfigParamUtils;
 import org.apache.myfaces.util.EnumerationIterator;
 import org.apache.myfaces.util.ExternalSpecifications;
@@ -358,7 +359,8 @@ public final class ServletExternalContextImpl extends ServletExternalContextImpl
     @Override
     public String encodeActionURL(final String url)
     {
-        checkNull(url, "url");
+        Assert.notNull(url, "url");
+
         checkHttpServletRequest();
         String encodedUrl = ((HttpServletResponse) _servletResponse).encodeURL(url);
         encodedUrl = encodeURL(encodedUrl, null);
@@ -374,7 +376,7 @@ public final class ServletExternalContextImpl extends ServletExternalContextImpl
     @Override
     public String encodeResourceURL(final String url)
     {
-        checkNull(url, "url");
+        Assert.notNull(url, "url");
         checkHttpServletRequest();
         String encodedUrl = ((HttpServletResponse) _servletResponse).encodeURL(url);
         
@@ -444,7 +446,7 @@ public final class ServletExternalContextImpl extends ServletExternalContextImpl
     @Override
     public String encodePartialActionURL(String url)
     {
-        checkNull(url, "url");
+        Assert.notNull(url, "url");
         checkHttpServletRequest();
         return encodeURL(((HttpServletResponse) _servletResponse).encodeURL(url), null);
     }
@@ -458,8 +460,8 @@ public final class ServletExternalContextImpl extends ServletExternalContextImpl
     @Override
     public String encodeWebsocketURL(String url)
     {
+        Assert.notNull(url, "url");
 
-        checkNull(url, "url");
         FacesContext facesContext = getCurrentFacesContext();
         Integer port = WebConfigParamUtils.getIntegerInitParameter(
                 getCurrentFacesContext().getExternalContext(), WEBSOCKET_ENDPOINT_PORT);
@@ -549,7 +551,7 @@ public final class ServletExternalContextImpl extends ServletExternalContextImpl
     @Override
     public boolean isUserInRole(final String role)
     {
-        checkNull(role, "role");
+        Assert.notNull(role, "role");
         checkHttpServletRequest();
         return _httpServletRequest.isUserInRole(role);
     }
@@ -860,7 +862,7 @@ public final class ServletExternalContextImpl extends ServletExternalContextImpl
 
     private String encodeURL(String baseUrl, Map<String, List<String>> parameters)
     {
-        checkNull(baseUrl, "url");
+        Assert.notNull(baseUrl, "url");
         checkHttpServletRequest();
 
         String fragment = null;
diff --git a/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImplBase.java
b/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImplBase.java
index 546d594..14e11a5 100644
--- a/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImplBase.java
+++ b/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImplBase.java
@@ -29,6 +29,7 @@ import javax.faces.lifecycle.ClientWindow;
 import javax.servlet.ServletContext;
 
 import org.apache.myfaces.context.ReleasableExternalContext;
+import org.apache.myfaces.util.Assert;
 
 /**
  * Provides a base implementation of the ExternalContext for Servlet
@@ -58,6 +59,7 @@ public abstract class ServletExternalContextImplBase extends ExternalContext
         _clientWindow = null;
     }
     
+    @Override
     public void release()
     {
         _servletContext = null;
@@ -81,7 +83,7 @@ public abstract class ServletExternalContextImplBase extends ExternalContext
     @Override
     public String getMimeType(String file)
     {
-        checkNull(file, "file");
+        Assert.notNull(file, "file");
         return _servletContext.getMimeType(file);
     }
     
@@ -98,13 +100,10 @@ public abstract class ServletExternalContextImplBase extends ExternalContext
     }
     
     @Override
-    public String getInitParameter(final String s)
+    public String getInitParameter(final String name)
     {
-        if (s == null)
-        {
-            throw new NullPointerException("Init parameter name cannot be null");
-        }
-        return _servletContext.getInitParameter(s);
+        Assert.notNull(name, "name");
+        return _servletContext.getInitParameter(name);
     }
 
     @Override
@@ -127,14 +126,14 @@ public abstract class ServletExternalContextImplBase extends ExternalContext
     @Override
     public URL getResource(final String path) throws MalformedURLException
     {
-        checkNull(path, "path");
+        Assert.notNull(path, "path");
         return _servletContext.getResource(path);
     }
 
     @Override
     public InputStream getResourceAsStream(final String path)
     {
-        checkNull(path, "path");
+        Assert.notNull(path, "path");
         return _servletContext.getResourceAsStream(path);
     }
 
@@ -142,37 +141,39 @@ public abstract class ServletExternalContextImplBase extends ExternalContext
     @SuppressWarnings("unchecked")
     public Set<String> getResourcePaths(final String path)
     {
-        checkNull(path, "path");
+        Assert.notNull(path, "path");
         return _servletContext.getResourcePaths(path);
     }
 
     @Override
     public void log(final String message)
     {
-        checkNull(message, "message");
+        Assert.notNull(message, "message");
         _servletContext.log(message);
     }
 
     @Override
     public void log(final String message, final Throwable exception)
     {
-        checkNull(message, "message");
-        checkNull(exception, "exception");
+        Assert.notNull(message, "message");
+        Assert.notNull(exception, "exception");
         _servletContext.log(message, exception);
     }
     
     @Override
     public String getRealPath(String path)
     {
-        checkNull(path, "path");
+        Assert.notNull(path, "path");
         return _servletContext.getRealPath(path);
     }
     
+    @Override
     public ClientWindow getClientWindow()
     {
         return _clientWindow;
     }
     
+    @Override
     public void setClientWindow(ClientWindow window)
     {
         _clientWindow = window;
@@ -183,16 +184,5 @@ public abstract class ServletExternalContextImplBase extends ExternalContext
     {
         return _servletContext.getContextPath();
         
-    }
-    
-    // ~ Methods which verify some required behavior---------------------------
-    
-    protected void checkNull(final Object o, final String param)
-    {
-        if (o == null)
-        {
-            throw new NullPointerException(param + " can not be null.");
-        }
-    }
-    
+    }    
 }
diff --git a/impl/src/main/java/org/apache/myfaces/flow/FlowHandlerImpl.java b/impl/src/main/java/org/apache/myfaces/flow/FlowHandlerImpl.java
index 3be97d7..fbd1485 100644
--- a/impl/src/main/java/org/apache/myfaces/flow/FlowHandlerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/flow/FlowHandlerImpl.java
@@ -42,6 +42,7 @@ import javax.faces.lifecycle.ClientWindow;
 import org.apache.myfaces.event.PostClientWindowAndViewInitializedEvent;
 import org.apache.myfaces.spi.FacesFlowProvider;
 import org.apache.myfaces.spi.FacesFlowProviderFactory;
+import org.apache.myfaces.util.Assert;
 
 /**
  *
@@ -71,9 +72,9 @@ public class FlowHandlerImpl extends FlowHandler implements SystemEventListener
     @Override
     public Flow getFlow(FacesContext context, String definingDocumentId, String id)
     {
-        checkNull(context, "context");
-        checkNull(definingDocumentId, "definingDocumentId");
-        checkNull(id, "id");
+        Assert.notNull(context, "context");
+        Assert.notNull(definingDocumentId, "definingDocumentId");
+        Assert.notNull(id, "id");
         
         // First try the combination.
         Map<String, Flow> flowMap = _flowMapByDocumentId.get(definingDocumentId);
@@ -97,8 +98,8 @@ public class FlowHandlerImpl extends FlowHandler implements SystemEventListener
     @Override
     public void addFlow(FacesContext context, Flow toAdd)
     {
-        checkNull(context, "context");
-        checkNull(toAdd, "toAdd");
+        Assert.notNull(context, "context");
+        Assert.notNull(toAdd, "toAdd");
         
         String id = toAdd.getId();
         String definingDocumentId = toAdd.getDefiningDocumentId();
@@ -191,8 +192,8 @@ public class FlowHandlerImpl extends FlowHandler implements SystemEventListener
     public void transition(FacesContext context, Flow sourceFlow, Flow targetFlow, 
         FlowCallNode outboundCallNode, String toViewId)
     {
-        checkNull(context, "context");
-        checkNull(toViewId, "toViewId");
+        Assert.notNull(context, "context");
+        Assert.notNull(toViewId, "toViewId");
         ClientWindow clientWindow = context.getExternalContext().getClientWindow();
         boolean outboundCallNodeProcessed = false;
         if (clientWindow == null)
@@ -425,9 +426,9 @@ public class FlowHandlerImpl extends FlowHandler implements SystemEventListener
     @Override
     public boolean isActive(FacesContext context, String definingDocumentId, String id)
     {
-        checkNull(context, "context");
-        checkNull(definingDocumentId, "definingDocumentId");
-        checkNull(id, "id");
+        Assert.notNull(context, "context");
+        Assert.notNull(definingDocumentId, "definingDocumentId");
+        Assert.notNull(id, "id");
         
         Object session = context.getExternalContext().getSession(false);
         if (session == null)
@@ -768,15 +769,7 @@ public class FlowHandlerImpl extends FlowHandler implements SystemEventListener
             }
         }
     }
-    
-    private void checkNull(final Object o, final String param)
-    {
-        if (o == null)
-        {
-            throw new NullPointerException(param + " can not be null.");
-        }
-    }
-    
+
     private void invokeInspectFlow(FacesContext context, NavigationHandler navHandler, Flow
toAdd)
     {
         if (navHandler instanceof ConfigurableNavigationHandler)
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/RenderKitFactoryImpl.java b/impl/src/main/java/org/apache/myfaces/renderkit/RenderKitFactoryImpl.java
index 69ac2f6..9cdffc2 100755
--- a/impl/src/main/java/org/apache/myfaces/renderkit/RenderKitFactoryImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/RenderKitFactoryImpl.java
@@ -70,10 +70,8 @@ public class RenderKitFactoryImpl extends RenderKitFactory
     @Override
     public RenderKit getRenderKit(FacesContext context, String renderKitId) throws FacesException
     {
-        if (renderKitId == null)
-        {
-            throw new NullPointerException("renderKitId");
-        }
+        Assert.notNull(renderKitId, "renderKitId");
+
         RenderKit renderkit = _renderkits.get(renderKitId);
         if (renderkit == null)
         {
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/_SharedRendererUtils.java b/impl/src/main/java/org/apache/myfaces/renderkit/_SharedRendererUtils.java
index 3a51363..b662d3a 100755
--- a/impl/src/main/java/org/apache/myfaces/renderkit/_SharedRendererUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/_SharedRendererUtils.java
@@ -45,6 +45,7 @@ import javax.faces.model.SelectItemGroup;
 
 import org.apache.myfaces.util.ComponentUtils;
 import org.apache.myfaces.renderkit.html.util.SelectItemsIterator;
+import org.apache.myfaces.util.Assert;
 
 /**
  * The util methods in this class are shared between the javax.faces.component package and
@@ -125,10 +126,7 @@ class _SharedRendererUtils
         // This code is duplicated in jsfapi component package (except for considerValueType).
         // If you change something here please do the same in the other class!
 
-        if (submittedValue == null)
-        {
-            throw new NullPointerException("submittedValue");
-        }
+        Assert.notNull(submittedValue, "submittedValue");
 
         ValueExpression expression = component.getValueExpression("value");
         Object targetForConvertedValues = null;
diff --git a/impl/src/main/java/org/apache/myfaces/util/Assert.java b/impl/src/main/java/org/apache/myfaces/util/Assert.java
index 3b542f8..c7f741c 100644
--- a/impl/src/main/java/org/apache/myfaces/util/Assert.java
+++ b/impl/src/main/java/org/apache/myfaces/util/Assert.java
@@ -28,11 +28,19 @@ public class Assert
         }
     }
     
-    public static void notNull(Object value, String fieldName)
+    public static void notNull(Object value, String name)
     {
         if (value == null)
         {
-            throw new NullPointerException(fieldName + " is null.");
+            throw new NullPointerException(name + " is null.");
+        }
+    }
+    
+    public static void notEmpty(String param, String name)
+    {
+        if (param == null || param.isEmpty())
+        {
+            throw new NullPointerException(name + " is empty.");
         }
     }
 }


Mime
View raw message