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 Tue, 13 Aug 2019 08:43:02 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 c3bb476  refactored
c3bb476 is described below

commit c3bb47699efd5d01f097505d04471c103b682f85
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Tue Aug 13 10:42:54 2019 +0200

    refactored
---
 api/src/main/java/javax/faces/model/DataModel.java |  2 +-
 .../java/javax/faces/model/IterableDataModel.java  |  2 +-
 .../java/javax/faces/model/ResultSetDataModel.java |  2 +-
 .../faces/validator/DoubleRangeValidator.java      | 15 +++--
 .../javax/faces/validator/LengthValidator.java     |  4 +-
 .../javax/faces/validator/LongRangeValidator.java  |  9 ++-
 .../faces/webapp/UIComponentClassicTagBase.java    | 64 ++++++++++------------
 7 files changed, 45 insertions(+), 53 deletions(-)

diff --git a/api/src/main/java/javax/faces/model/DataModel.java b/api/src/main/java/javax/faces/model/DataModel.java
index fcd8dc3..9843978 100644
--- a/api/src/main/java/javax/faces/model/DataModel.java
+++ b/api/src/main/java/javax/faces/model/DataModel.java
@@ -62,7 +62,7 @@ public abstract class DataModel<E> implements Iterable<E>
         }
         if (_listeners == null)
         {
-            _listeners = new ArrayList<DataModelListener>();
+            _listeners = new ArrayList<>();
         }
         _listeners.add(listener);
         _cachedListenersArray = null;
diff --git a/api/src/main/java/javax/faces/model/IterableDataModel.java b/api/src/main/java/javax/faces/model/IterableDataModel.java
index def23e5..e50b4e2 100644
--- a/api/src/main/java/javax/faces/model/IterableDataModel.java
+++ b/api/src/main/java/javax/faces/model/IterableDataModel.java
@@ -104,7 +104,7 @@ public class IterableDataModel<E> extends DataModel<E>
             {
                 if (_list == null)
                 {
-                    _list = new ArrayList<E>();
+                    _list = new ArrayList<>();
                 }
                 if (_iterator == null && _iterable != null)
                 {
diff --git a/api/src/main/java/javax/faces/model/ResultSetDataModel.java b/api/src/main/java/javax/faces/model/ResultSetDataModel.java
index b8cfacb..4e34977 100755
--- a/api/src/main/java/javax/faces/model/ResultSetDataModel.java
+++ b/api/src/main/java/javax/faces/model/ResultSetDataModel.java
@@ -78,7 +78,7 @@ public class ResultSetDataModel extends DataModel<Map<String,Object>>
      * returned from here, so check the spec before modifying anything here.
      */
     @Override
-    public Map<String,Object> getRowData()
+    public Map<String, Object> getRowData()
     {
         if (_resultSet == null)
         {
diff --git a/api/src/main/java/javax/faces/validator/DoubleRangeValidator.java b/api/src/main/java/javax/faces/validator/DoubleRangeValidator.java
index 1c3af71..068fb8a 100755
--- a/api/src/main/java/javax/faces/validator/DoubleRangeValidator.java
+++ b/api/src/main/java/javax/faces/validator/DoubleRangeValidator.java
@@ -98,8 +98,7 @@ public class DoubleRangeValidator
         double dvalue = parseDoubleValue(facesContext, uiComponent,value);
         if (_minimum != null && _maximum != null)
         {
-            if (dvalue < _minimum.doubleValue() ||
-                dvalue > _maximum.doubleValue())
+            if (dvalue < _minimum || dvalue > _maximum)
             {
                 Object[] args = {_minimum, _maximum,_MessageUtils.getLabel(facesContext,
uiComponent)};
                 throw new ValidatorException(_MessageUtils.getErrorMessage(facesContext,
NOT_IN_RANGE_MESSAGE_ID,
@@ -108,7 +107,7 @@ public class DoubleRangeValidator
         }
         else if (_minimum != null)
         {
-            if (dvalue < _minimum.doubleValue())
+            if (dvalue < _minimum)
             {
                 Object[] args = {_minimum,_MessageUtils.getLabel(facesContext, uiComponent)};
                 throw new ValidatorException(_MessageUtils.getErrorMessage(facesContext,
MINIMUM_MESSAGE_ID, args));
@@ -116,7 +115,7 @@ public class DoubleRangeValidator
         }
         else if (_maximum != null)
         {
-            if (dvalue > _maximum.doubleValue())
+            if (dvalue > _maximum)
             {
                 Object[] args = {_maximum,_MessageUtils.getLabel(facesContext, uiComponent)};
                 throw new ValidatorException(_MessageUtils.getErrorMessage(facesContext,
MAXIMUM_MESSAGE_ID, args));
@@ -153,12 +152,12 @@ public class DoubleRangeValidator
     @JSFProperty(deferredValueType="java.lang.Double")
     public double getMaximum()
     {
-        return _maximum != null ? _maximum.doubleValue() : Double.MAX_VALUE;
+        return _maximum != null ? _maximum : Double.MAX_VALUE;
     }
 
     public void setMaximum(double maximum)
     {
-        _maximum = new Double(maximum);
+        _maximum = Double.valueOf(maximum);
         clearInitialState();
     }
 
@@ -169,12 +168,12 @@ public class DoubleRangeValidator
     @JSFProperty(deferredValueType="java.lang.Double")
     public double getMinimum()
     {
-        return _minimum != null ? _minimum.doubleValue() : Double.MIN_VALUE;
+        return _minimum != null ? _minimum : Double.MIN_VALUE;
     }
 
     public void setMinimum(double minimum)
     {
-        _minimum = new Double(minimum);
+        _minimum = Double.valueOf(minimum);
         clearInitialState();
     }
 
diff --git a/api/src/main/java/javax/faces/validator/LengthValidator.java b/api/src/main/java/javax/faces/validator/LengthValidator.java
index 5f27854..22df8e4 100755
--- a/api/src/main/java/javax/faces/validator/LengthValidator.java
+++ b/api/src/main/java/javax/faces/validator/LengthValidator.java
@@ -130,7 +130,7 @@ public class LengthValidator
 
     public void setMaximum(int maximum)
     {
-        _maximum = maximum;
+        _maximum = Integer.valueOf(maximum);
         clearInitialState();
     }
 
@@ -146,7 +146,7 @@ public class LengthValidator
 
     public void setMinimum(int minimum)
     {
-        _minimum = minimum;
+        _minimum = Integer.valueOf(minimum);
         clearInitialState();
     }
 
diff --git a/api/src/main/java/javax/faces/validator/LongRangeValidator.java b/api/src/main/java/javax/faces/validator/LongRangeValidator.java
index 5bf473f..2a4fc0e 100755
--- a/api/src/main/java/javax/faces/validator/LongRangeValidator.java
+++ b/api/src/main/java/javax/faces/validator/LongRangeValidator.java
@@ -99,8 +99,7 @@ public class LongRangeValidator
         double dvalue = parseLongValue(facesContext, uiComponent,value);
         if (_minimum != null && _maximum != null)
         {
-            if (dvalue < _minimum.longValue() ||
-                dvalue > _maximum.longValue())
+            if (dvalue < _minimum || dvalue > _maximum)
             {
                 Object[] args = {_minimum, _maximum,_MessageUtils.getLabel(facesContext,
uiComponent)};
                 throw new ValidatorException(_MessageUtils.getErrorMessage(facesContext,
@@ -109,7 +108,7 @@ public class LongRangeValidator
         }
         else if (_minimum != null)
         {
-            if (dvalue < _minimum.longValue())
+            if (dvalue < _minimum)
             {
                 Object[] args = {_minimum,_MessageUtils.getLabel(facesContext, uiComponent)};
                 throw new ValidatorException(_MessageUtils.getErrorMessage(facesContext,
MINIMUM_MESSAGE_ID, args));
@@ -117,7 +116,7 @@ public class LongRangeValidator
         }
         else if (_maximum != null)
         {
-            if (dvalue > _maximum.longValue())
+            if (dvalue > _maximum)
             {
                 Object[] args = {_maximum,_MessageUtils.getLabel(facesContext, uiComponent)};
                 throw new ValidatorException(_MessageUtils.getErrorMessage(facesContext,
MAXIMUM_MESSAGE_ID, args));
@@ -155,7 +154,7 @@ public class LongRangeValidator
     @JSFProperty(deferredValueType="java.lang.Long")
     public long getMaximum()
     {
-        return _maximum != null ? _maximum.longValue() : Long.MAX_VALUE;
+        return _maximum != null ? _maximum : Long.MAX_VALUE;
     }
 
     public void setMaximum(long maximum)
diff --git a/api/src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java b/api/src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java
index ac5a4d0..96dc183 100644
--- a/api/src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java
+++ b/api/src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java
@@ -98,6 +98,7 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
 
     protected abstract UIComponent createComponent(FacesContext context, String newId) throws
JspException;
 
+    @Override
     public void release()
     {
         internalRelease();
@@ -152,6 +153,7 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
         return _jspId;
     }
 
+    @Override
     public void setJspId(String jspId)
     {
         // -= Leonardo Uribe =- The javadoc says the following about this method:
@@ -342,17 +344,20 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
         return _facesJspId;
     }
 
+    @Override
     public void setBodyContent(BodyContent bodyContent)
     {
         this.bodyContent = bodyContent;
     }
 
+    @Override
     public void doInitBody() throws JspException
     {
         // nothing by default
     }
 
     @SuppressWarnings("unchecked")
+    @Override
     public int doAfterBody() throws JspException
     {
         UIComponentClassicTagBase parentTag = getParentUIComponentClassicTagBase(pageContext);
@@ -399,6 +404,7 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
      * Standard method invoked by the JSP framework to inform this tag of the PageContext
associated with the jsp page
      * currently being processed.
      */
+    @Override
     public void setPageContext(PageContext pageContext)
     {
         this.pageContext = pageContext;
@@ -407,6 +413,7 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
     /**
      * Returns the enclosing JSP tag object. Note that this is not necessarily a JSF tag.
      */
+    @Override
     public Tag getParent()
     {
         return _parent;
@@ -415,6 +422,7 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
     /**
      * Standard method invoked by the JSP framework to inform this tag of the enclosing JSP
tag object.
      */
+    @Override
     public void setParent(Tag tag)
     {
         this._parent = tag;
@@ -425,6 +433,7 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
         return bodyContent;
     }
 
+    @Override
     public int doStartTag() throws JspException
     {
         this._facesContext = getFacesContext();
@@ -531,6 +540,7 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
         return getDoStartValue();
     }
 
+    @Override
     public int doEndTag() throws JspException
     {
         popTag();
@@ -837,25 +847,20 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
         }
         else
         {
-            viewComponentIds = (Map<String, Object>) attributes.get(VIEW_IDS);
-            
             // Check if null, this can happen if someone programatically tries to do an include
of a 
             // JSP fragment. This code will prevent NullPointerException from happening in
such cases.
-            if (viewComponentIds == null)
-            {
-                viewComponentIds = new HashMap<String, Object>();
-                attributes.put(VIEW_IDS, viewComponentIds);
-            }
+            viewComponentIds = (Map<String, Object>) attributes.computeIfAbsent(VIEW_IDS,
+                    k -> new HashMap<String, Object>());
         }
 
         return viewComponentIds;
     }
 
     @SuppressWarnings("unchecked")
-    private static final Stack<UIComponentClassicTagBase> getStack(PageContext pageContext)
+    private static Stack<UIComponentClassicTagBase> getStack(PageContext pageContext)
     {
         Stack<UIComponentClassicTagBase> stack =
-                (Stack<UIComponentClassicTagBase>)pageContext.getAttribute(COMPONENT_STACK_ATTR,
+                (Stack<UIComponentClassicTagBase>) pageContext.getAttribute(COMPONENT_STACK_ATTR,
                     PageContext.REQUEST_SCOPE);
 
         if (stack == null)
@@ -1044,7 +1049,6 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
         // and ask it for its component. If there is no parent UIComponentTag instance,
         // this tag represents the root component, so get it from the current Tree and return
it.
         UIComponentClassicTagBase parentTag = getParentUIComponentClassicTagBase(pageContext);
-
         if (parentTag == null)
         {
             // This is the root
@@ -1052,7 +1056,6 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
 
             // check if the view root is already bound to the tag
             Object alreadyBoundViewRootFlag = _componentInstance.getAttributes().get(BOUND_VIEW_ROOT);
-
             if (alreadyBoundViewRootFlag == null)
             {
                 try
@@ -1149,16 +1152,16 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
             _componentInstance = createComponent(context, id);
             if (id.equals(_componentInstance.getId()) )
             {
-            _created = true;
-            int index = parentTag.getIndexOfNextChildTag();
-            if (index > parent.getChildCount())
-            {
-                index = parent.getChildCount();
-            }
+                _created = true;
+                int index = parentTag.getIndexOfNextChildTag();
+                if (index > parent.getChildCount())
+                {
+                    index = parent.getChildCount();
+                }
 
-            List<UIComponent> children = parent.getChildren();
-            children.add(index, _componentInstance);
-        }
+                List<UIComponent> children = parent.getChildren();
+                children.add(index, _componentInstance);
+            }
             // On weblogic portal using faces-adapter, the id set and the retrieved 
             // one for <netuix:namingContainer> is different. The reason is 
             // this custom solution for integrate jsf changes the id of the parent
@@ -1213,7 +1216,6 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
             {
                 if (parent != null)
                 {
-
                     UIComponent namingContainer;
 
                     if (parent instanceof NamingContainer)
@@ -1280,18 +1282,10 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
     @SuppressWarnings("unchecked")
     private Set<String> getPreviousJspIdsSet()
     {
-        Set<String> previousJspIdsSet =
-                (Set<String>)getFacesContext().getAttributes().get(PREVIOUS_JSP_IDS_SET);
-
-        if (previousJspIdsSet == null)
-        {
-            previousJspIdsSet = new HashSet<String>();
-            // Add it to the context! The next time is called
-            // this method it takes the ref from the RequestContext
-            getFacesContext().getAttributes().put(PREVIOUS_JSP_IDS_SET, previousJspIdsSet);
-        }
-
-        return previousJspIdsSet;
+        // Add it to the context! The next time is called
+        // this method it takes the ref from the RequestContext
+        return (Set<String>)getFacesContext().getAttributes().computeIfAbsent(PREVIOUS_JSP_IDS_SET,
+                        k -> new HashSet<>());
     }
 
     private boolean isIdDuplicated(String componentId)
@@ -1303,8 +1297,8 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
             {
                 return true;
             }
-            List<String> childComponents = _parentClassicTag.getCreatedComponents();
 
+            List<String> childComponents = _parentClassicTag.getCreatedComponents();
             if (childComponents != null)
             {
                 result = childComponents.contains(componentId);
@@ -1340,7 +1334,7 @@ public abstract class UIComponentClassicTagBase extends UIComponentTagBase
imple
     {
         if (parentTag._facetsAdded == null)
         {
-            parentTag._facetsAdded = new ArrayList<String>();
+            parentTag._facetsAdded = new ArrayList<>();
         }
         parentTag._facetsAdded.add(facetName);
     }


Mime
View raw message