polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [39/50] [abbrv] zest-qi4j git commit: Replacing loops with Stream API, and a use of Method reference.
Date Fri, 17 Apr 2015 16:08:51 GMT
Replacing loops with Stream API, and a use of Method reference.


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/aee712a1
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/aee712a1
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/aee712a1

Branch: refs/heads/3.0
Commit: aee712a18251563827590d350b7597736d70fac7
Parents: 0a50ebd
Author: Niclas Hedhman <niclas@hedhman.org>
Authored: Sat Oct 4 14:14:20 2014 +0800
Committer: Niclas Hedhman <niclas@hedhman.org>
Committed: Sat Oct 4 14:14:20 2014 +0800

----------------------------------------------------------------------
 .../main/java/org/qi4j/api/common/MetaInfo.java | 24 ++++++++------------
 1 file changed, 9 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/aee712a1/core/api/src/main/java/org/qi4j/api/common/MetaInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/MetaInfo.java b/core/api/src/main/java/org/qi4j/api/common/MetaInfo.java
index 9fd084c..2266207 100644
--- a/core/api/src/main/java/org/qi4j/api/common/MetaInfo.java
+++ b/core/api/src/main/java/org/qi4j/api/common/MetaInfo.java
@@ -17,6 +17,7 @@ package org.qi4j.api.common;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Type;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -80,7 +81,7 @@ public final class MetaInfo
 
     static
     {
-        ignored = new HashSet<Class>( 4, 0.8f ); // Optimize size used.
+        ignored = new HashSet<>( 4, 0.8f ); // Optimize size used.
         ignored.addAll( asList( Mixins.class, Concerns.class, SideEffects.class ) );
     }
 
@@ -88,12 +89,12 @@ public final class MetaInfo
 
     public MetaInfo()
     {
-        metaInfoMap = new LinkedHashMap<Class<?>, Object>();
+        metaInfoMap = new LinkedHashMap<>();
     }
 
     public MetaInfo( MetaInfo metaInfo )
     {
-        metaInfoMap = new LinkedHashMap<Class<?>, Object>();
+        metaInfoMap = new LinkedHashMap<>();
         metaInfoMap.putAll( metaInfo.metaInfoMap );
     }
 
@@ -108,10 +109,7 @@ public final class MetaInfo
         {
             Class<?> metaInfoclass = metaInfo.getClass();
             Iterable<Type> types = typesOf( metaInfoclass );
-            for( Type type : types )
-            {
-                metaInfoMap.put( Classes.RAW_CLASS.apply( type ), metaInfo );
-            }
+            types.forEach( type -> metaInfoMap.put( Classes.RAW_CLASS.apply( type ), metaInfo
) );
         }
     }
 
@@ -127,14 +125,10 @@ public final class MetaInfo
 
     public MetaInfo withAnnotations( AnnotatedElement annotatedElement )
     {
-        for( Annotation annotation : annotatedElement.getAnnotations() )
-        {
-            if( !ignored.contains( annotation.annotationType() )
-                && get( annotation.annotationType() ) == null )
-            {
-                set( annotation );
-            }
-        }
+        Arrays.stream( annotatedElement.getAnnotations() )
+            .filter( annotation -> !ignored.contains( annotation.annotationType() )
+                   && get( annotation.annotationType() ) == null )
+            .forEach( this::set );
         return this;
     }
 


Mime
View raw message