myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] 01/02: cosmetics
Date Fri, 02 Aug 2019 09:45:22 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

commit f955a3b7a266b8d8abb1c1c73952f1a63a76133f
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Fri Aug 2 10:54:57 2019 +0200

    cosmetics
---
 .../myfaces/view/facelets/tag/MetaRulesetImpl.java | 23 +++++-----------------
 .../myfaces/view/facelets/tag/TagHandlerUtils.java |  2 +-
 .../tag/jsf/ComponentTagHandlerDelegate.java       | 10 ++--------
 3 files changed, 8 insertions(+), 27 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java
b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java
index 50fae73..13d9e32 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java
@@ -46,8 +46,6 @@ import org.apache.myfaces.view.facelets.tag.jsf.PassThroughLibrary;
  */
 public final class MetaRulesetImpl extends MetaRuleset
 {
-    private final static Metadata NONE = new NullMetadata();
-
     private final static Logger log = Logger.getLogger(MetaRulesetImpl.class.getName());
 
     /**
@@ -83,23 +81,13 @@ public final class MetaRulesetImpl extends MetaRuleset
             // per classloader to hold metadata.
             synchronized (MetaRulesetImpl.metadata)
             {
-                metadata = createMetaData(cl, metadata);
+                metadata = MetaRulesetImpl.metadata.computeIfAbsent(cl,
+                    k -> new HashMap<>());
             }
         }
 
         return metadata;
     }
-    
-    private static Map<String, MetadataTarget> createMetaData(ClassLoader cl, Map<String,
MetadataTarget> metadata)
-    {
-        metadata = (Map<String, MetadataTarget>) MetaRulesetImpl.metadata.get(cl);
-        if (metadata == null)
-        {
-            metadata = new HashMap<String, MetadataTarget>();
-            MetaRulesetImpl.metadata.put(cl, metadata);
-        }
-        return metadata;
-    }
 
     private final static TagAttribute[] EMPTY = new TagAttribute[0];
     
@@ -301,7 +289,7 @@ public final class MetaRulesetImpl extends MetaRuleset
 
         if (_mappers.isEmpty())
         {
-            return NONE;
+            return NullMetadata.INSTANCE;
         }
         else
         {
@@ -360,9 +348,8 @@ public final class MetaRulesetImpl extends MetaRuleset
 
     private static class NullMetadata extends Metadata
     {
-        /**
-         * {@inheritDoc}
-         */
+        public static final NullMetadata INSTANCE = new NullMetadata();
+        
         @Override
         public void applyMetadata(FaceletContext ctx, Object instance)
         {
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerUtils.java
b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerUtils.java
index c41eced..c758b29 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerUtils.java
@@ -133,7 +133,7 @@ public final class TagHandlerUtils
 
     public static ArrayList<FaceletHandler> findNextByType(FaceletHandler nextHandler,
Class<?> type1, Class<?> type2)
     {
-        ArrayList<FaceletHandler> found = new ArrayList<FaceletHandler>();
+        ArrayList<FaceletHandler> found = new ArrayList<>();
         if (type1.isAssignableFrom(nextHandler.getClass()) || type2.isAssignableFrom(nextHandler.getClass()))
         {
             found.add((FaceletHandler)nextHandler);
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
index 2502bfa..0396b7e 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
@@ -84,15 +84,10 @@ public class ComponentTagHandlerDelegate extends TagHandlerDelegate
     private final static Logger log = Logger.getLogger(ComponentTagHandlerDelegate.class.getName());
 
     private final ComponentHandler _delegate;
-
     private final String _componentType;
-
     private final TagAttribute _id;
-
     private final String _rendererType;
-    
     private final ComponentBuilderHandler _componentBuilderHandlerDelegate;
-    
     private final RelocatableResourceHandler _relocatableResourceHandler;
 
     @SuppressWarnings("unchecked")
@@ -780,8 +775,7 @@ public class ComponentTagHandlerDelegate extends TagHandlerDelegate
                                               String validatorId)
     {
         // check if the validatorId is on the exclusion list on the component
-        List<String> exclusionList 
-                = (List<String>) ((UIComponent) component).getAttributes()
+        List<String> exclusionList = (List<String>) ((UIComponent) component).getAttributes()
                         .get(ValidatorTagHandlerDelegate.VALIDATOR_ID_EXCLUSION_LIST_KEY);
         if (exclusionList != null)
         {
@@ -804,7 +798,7 @@ public class ComponentTagHandlerDelegate extends TagHandlerDelegate
                 boolean validatorIdAvailable = entry.getKey() != null && !entry.getKey().isEmpty();
                 if (validatorIdAvailable && entry.getKey().equals(validatorId))
                 {
-                    if (((ValidatorHandler)((FacesWrapper<ValidatorHandler>)entry.getValue()).getWrapped())
+                    if (((ValidatorHandler) ((FacesWrapper<ValidatorHandler>) entry.getValue()).getWrapped())
                             .isDisabled(ctx))
                     {
                         return false;


Mime
View raw message