Return-Path: X-Original-To: apmail-zest-commits-archive@minotaur.apache.org Delivered-To: apmail-zest-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 642EC17E33 for ; Fri, 17 Apr 2015 16:08:15 +0000 (UTC) Received: (qmail 48510 invoked by uid 500); 17 Apr 2015 16:08:15 -0000 Delivered-To: apmail-zest-commits-archive@zest.apache.org Received: (qmail 48443 invoked by uid 500); 17 Apr 2015 16:08:15 -0000 Mailing-List: contact commits-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list commits@zest.apache.org Received: (qmail 48375 invoked by uid 99); 17 Apr 2015 16:08:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Apr 2015 16:08:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1BCC1E0280; Fri, 17 Apr 2015 16:08:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: niclas@apache.org To: commits@zest.apache.org Date: Fri, 17 Apr 2015 16:08:51 -0000 Message-Id: In-Reply-To: <2da16a2ab3144bd6bd2beabd68134615@git.apache.org> References: <2da16a2ab3144bd6bd2beabd68134615@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [39/50] [abbrv] zest-qi4j git commit: Replacing loops with Stream API, and a use of Method reference. 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 Authored: Sat Oct 4 14:14:20 2014 +0800 Committer: Niclas Hedhman 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( 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, Object>(); + metaInfoMap = new LinkedHashMap<>(); } public MetaInfo( MetaInfo metaInfo ) { - metaInfoMap = new LinkedHashMap, Object>(); + metaInfoMap = new LinkedHashMap<>(); metaInfoMap.putAll( metaInfo.metaInfoMap ); } @@ -108,10 +109,7 @@ public final class MetaInfo { Class metaInfoclass = metaInfo.getClass(); Iterable 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; }