You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2016/11/28 18:27:27 UTC

[3/5] zest-java git commit: remove some more uses of core/functional

remove some more uses of core/functional


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

Branch: refs/heads/develop
Commit: 398a5e8c9e542a18d428d4af8b9b2ac71b69d75a
Parents: a660c71
Author: Paul Merlin <pa...@apache.org>
Authored: Mon Nov 28 18:49:24 2016 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Mon Nov 28 18:49:24 2016 +0100

----------------------------------------------------------------------
 .../zest/bootstrap/builder/LayerDeclaration.java       |  7 +++++--
 .../zest/bootstrap/builder/ModuleDeclaration.java      | 13 ++++++-------
 .../zest/bootstrap/builder/ApplicationBuilderTest.java |  8 ++++----
 .../zest/library/rest/server/api/ObjectSelection.java  |  5 ++---
 4 files changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/398a5e8c/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
index 65936cc..96e712f 100644
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
+++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
@@ -23,11 +23,13 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.StreamSupport;
 import org.apache.zest.bootstrap.ApplicationAssembly;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.LayerAssembly;
 import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.functional.Iterables;
+
+import static java.util.stream.Collectors.toCollection;
 
 /**
  * Provides declared {@link org.apache.zest.api.structure.Layer} information that the {@link ApplicationBuilder} can use.
@@ -62,7 +64,8 @@ public class LayerDeclaration
      */
     public LayerDeclaration using( Iterable<String> layerNames )
     {
-        Iterables.addAll( using, layerNames );
+        StreamSupport.stream( layerNames.spliterator(), false )
+                     .collect( toCollection( () -> using ) );
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/398a5e8c/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
index 7401482..0a4b5fa 100644
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
+++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
@@ -21,14 +21,14 @@ package org.apache.zest.bootstrap.builder;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.StreamSupport;
 import org.apache.zest.bootstrap.Assembler;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.LayerAssembly;
 import org.apache.zest.bootstrap.ModuleAssembly;
 
+import static java.util.stream.Collectors.toList;
 import static org.apache.zest.api.util.Classes.isAssignableFrom;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.toList;
 
 /**
  * Provides declared {@link org.apache.zest.api.structure.Module} information that the {@link ApplicationBuilder} can use.
@@ -88,15 +88,14 @@ public class ModuleDeclaration
      * <p>Typically used along {@link org.apache.zest.bootstrap.ClassScanner}.</p>
      * @param assemblerClasses Assembler classes
      * @return This Module declaration
-     * @throws AssemblyException if one of the Class is not an Assembler or unable to instanciate
+     * @throws AssemblyException if one of the Class is not an Assembler or unable to instantiate
      */
     public ModuleDeclaration withAssemblers( Iterable<Class<?>> assemblerClasses )
         throws AssemblyException
     {
-        List<Class<?>> notAssemblers = toList(
-            filter( isAssignableFrom( Assembler.class ).negate(),
-                    assemblerClasses )
-        );
+        List<Class<?>> notAssemblers = StreamSupport.stream( assemblerClasses.spliterator(), false )
+                                                    .filter( isAssignableFrom( Assembler.class ).negate() )
+                                                    .collect( toList() );
         if( !notAssemblers.isEmpty() )
         {
             throw new AssemblyException(

http://git-wip-us.apache.org/repos/asf/zest-java/blob/398a5e8c/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java
index a07d92a..e30a3e0 100644
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java
+++ b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java
@@ -35,7 +35,6 @@ import org.junit.Test;
 import static java.util.stream.Collectors.toList;
 import static org.apache.zest.bootstrap.ClassScanner.findClasses;
 import static org.apache.zest.bootstrap.ClassScanner.matches;
-import static org.apache.zest.functional.Iterables.filter;
 import static org.hamcrest.core.IsEqual.equalTo;
 import static org.junit.Assert.assertThat;
 
@@ -48,9 +47,10 @@ public class ApplicationBuilderTest
         ApplicationBuilder builder = new ApplicationBuilder( "Build from API test." );
         builder.withLayer( "layer1" ).using( "layer2" ).using( "layer3" );
         builder.withLayer( "layer2" );
-        builder.withLayer( "layer3" ).withModule( "test module" ).
-            withAssemblers( filter( matches( ".*ServiceAssembler" ),
-                                    findClasses( getClass() ).collect( toList() ) ) );
+        builder.withLayer( "layer3" )
+               .withModule( "test module" )
+               .withAssemblers( findClasses( getClass() ).filter( matches( ".*ServiceAssembler" ) )
+                                                         .collect( toList() ) );
         Application application = builder.newApplication();
         Module module = application.findModule( "layer3", "test module" );
         TestService service = module.findService( TestService.class ).get();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/398a5e8c/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ObjectSelection.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ObjectSelection.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ObjectSelection.java
index 3fb146a..951d77f 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ObjectSelection.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ObjectSelection.java
@@ -23,7 +23,6 @@ package org.apache.zest.library.rest.server.api;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import org.apache.zest.functional.Iterables;
 import org.restlet.Request;
 
 /**
@@ -83,11 +82,11 @@ public class ObjectSelection
 
     public List<Object> selection()
     {
-        return Collections.unmodifiableList(selection);
+        return Collections.unmodifiableList( selection );
     }
 
     public Object[] toArray()
     {
-        return Iterables.toArray( Object.class, selection );
+        return selection.toArray( new Object[ selection.size() ] );
     }
 }