polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [12/24] zest-java git commit: ZEST-118; Massive update of removing the Iterable<> use for type manipulation in the runtime internals and all public APIs of that.
Date Wed, 26 Aug 2015 15:45:15 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bd6fbad9/tools/envisage/src/main/java/org/apache/zest/envisage/detail/GeneralPane.java
----------------------------------------------------------------------
diff --git a/tools/envisage/src/main/java/org/apache/zest/envisage/detail/GeneralPane.java
b/tools/envisage/src/main/java/org/apache/zest/envisage/detail/GeneralPane.java
index 1ccb498..0e416f8 100644
--- a/tools/envisage/src/main/java/org/apache/zest/envisage/detail/GeneralPane.java
+++ b/tools/envisage/src/main/java/org/apache/zest/envisage/detail/GeneralPane.java
@@ -40,8 +40,6 @@ import org.apache.zest.tools.model.descriptor.ServiceDetailDescriptor;
 import org.apache.zest.tools.model.descriptor.TransientDetailDescriptor;
 import org.apache.zest.tools.model.descriptor.ValueDetailDescriptor;
 
-import static org.apache.zest.functional.Iterables.first;
-
 /**
  * Implementation of General DetailPane
  */
@@ -80,7 +78,6 @@ import static org.apache.zest.functional.Iterables.first;
         tableModel.reload( objectDesciptor );
     }
 
-    
     {
 // GUI initializer generated by IntelliJ IDEA GUI Designer
 // >>> IMPORTANT!! <<<
@@ -92,7 +89,6 @@ import static org.apache.zest.functional.Iterables.first;
      * Method generated by IntelliJ IDEA GUI Designer
      * >>> IMPORTANT!! <<<
      * DO NOT edit this method OR call it in your code!
-     *
      */
     private void $$$setupUI$$$()
     {
@@ -116,10 +112,10 @@ import static org.apache.zest.functional.Iterables.first;
          * the column names for this model
          */
         private static final String[] COLUMN_NAMES =
-        {
-            BUNDLE.getString( "Name.Column" ),
-            BUNDLE.getString( "Value.Column" )
-        };
+            {
+                BUNDLE.getString( "Name.Column" ),
+                BUNDLE.getString( "Value.Column" )
+            };
         private final ArrayList<TableRow> rows;
 
         private final String nameRow = "name";
@@ -138,13 +134,14 @@ import static org.apache.zest.functional.Iterables.first;
             if( objectDesciptor instanceof ServiceDetailDescriptor )
             {
                 ServiceDescriptor descriptor = ( (ServiceDetailDescriptor) objectDesciptor
).descriptor();
-                Class<?> type = first( descriptor.types() );
+                Class<?> type = descriptor.types().findFirst().get();
                 rows.add( new TableRow( 2, nameRow, type.getSimpleName() ) );
                 rows.add( new TableRow( 2, classRow, type.getName() ) );
                 rows.add( new TableRow( 2, visibilityRow, descriptor.visibility().toString()
) );
                 rows.add( new TableRow( 2, moduleRow, ( (ServiceDetailDescriptor) objectDesciptor
).module() ) );
                 rows.add( new TableRow( 2, layerRow, ( (ServiceDetailDescriptor) objectDesciptor
).module().layer() ) );
-                rows.add( new TableRow( 2, "startup", ( (ServiceDetailDescriptor) objectDesciptor
).descriptor().isInstantiateOnStartup() ) );
+                rows.add( new TableRow( 2, "startup", ( (ServiceDetailDescriptor) objectDesciptor
).descriptor()
+                    .isInstantiateOnStartup() ) );
             }
             else if( objectDesciptor instanceof ImportedServiceDetailDescriptor )
             {
@@ -153,12 +150,13 @@ import static org.apache.zest.functional.Iterables.first;
                 rows.add( new TableRow( 2, classRow, descriptor.primaryType().getName() )
);
                 rows.add( new TableRow( 2, visibilityRow, descriptor.visibility().toString()
) );
                 rows.add( new TableRow( 2, moduleRow, ( (ImportedServiceDetailDescriptor)
objectDesciptor ).module() ) );
-                rows.add( new TableRow( 2, layerRow, ( (ImportedServiceDetailDescriptor)
objectDesciptor ).module().layer() ) );
+                rows.add( new TableRow( 2, layerRow, ( (ImportedServiceDetailDescriptor)
objectDesciptor ).module()
+                    .layer() ) );
             }
             else if( objectDesciptor instanceof EntityDetailDescriptor )
             {
                 EntityDescriptor descriptor = ( (EntityDetailDescriptor) objectDesciptor
).descriptor();
-                Class<?> type = first( descriptor.types() );
+                Class<?> type = descriptor.types().findFirst().orElse( null );
                 rows.add( new TableRow( 2, nameRow, type.getSimpleName() ) );
                 rows.add( new TableRow( 2, classRow, type.getName() ) );
                 rows.add( new TableRow( 2, visibilityRow, descriptor.visibility().toString()
) );
@@ -168,32 +166,17 @@ import static org.apache.zest.functional.Iterables.first;
             else if( objectDesciptor instanceof ValueDetailDescriptor )
             {
                 ValueDescriptor descriptor = ( (ValueDetailDescriptor) objectDesciptor ).descriptor();
-                Class<?> type = first( descriptor.types() );
-                rows.add( new TableRow( 2, new Object[]
-                {
-                    nameRow, type.getSimpleName()
-                } ) );
-                rows.add( new TableRow( 2, new Object[]
-                {
-                    classRow, type.getName()
-                } ) );
-                rows.add( new TableRow( 2, new Object[]
-                {
-                    visibilityRow, descriptor.visibility().toString()
-                } ) );
-                rows.add( new TableRow( 2, new Object[]
-                {
-                    moduleRow, ( (ValueDetailDescriptor) objectDesciptor ).module()
-                } ) );
-                rows.add( new TableRow( 2, new Object[]
-                {
-                    layerRow, ( (ValueDetailDescriptor) objectDesciptor ).module().layer()
-                } ) );
+                Class<?> type = descriptor.types().findFirst().orElse( null );
+                rows.add( new TableRow( 2, nameRow, type.getSimpleName() ) );
+                rows.add( new TableRow( 2, classRow, type.getName() ) );
+                rows.add( new TableRow( 2, visibilityRow, descriptor.visibility().toString()
) );
+                rows.add( new TableRow( 2, moduleRow, ( (ValueDetailDescriptor) objectDesciptor
).module() ) );
+                rows.add( new TableRow( 2, layerRow, ( (ValueDetailDescriptor) objectDesciptor
).module().layer() ) );
             }
             else if( objectDesciptor instanceof ObjectDetailDescriptor )
             {
                 ObjectDescriptor descriptor = ( (ObjectDetailDescriptor) objectDesciptor
).descriptor();
-                Class<?> type = first( descriptor.types() );
+                Class<?> type = descriptor.types().findFirst().orElse( null );
                 rows.add( new TableRow( 2, nameRow, type.getSimpleName() ) );
                 rows.add( new TableRow( 2, classRow, type.getName() ) );
                 rows.add( new TableRow( 2, visibilityRow, descriptor.visibility().toString()
) );
@@ -203,12 +186,13 @@ import static org.apache.zest.functional.Iterables.first;
             else if( objectDesciptor instanceof TransientDetailDescriptor )
             {
                 CompositeDescriptor descriptor = ( (TransientDetailDescriptor) objectDesciptor
).descriptor();
-                Class<?> type = first( descriptor.types() );
+                Class<?> type = descriptor.types().findFirst().orElse( null );
                 rows.add( new TableRow( 2, nameRow, type.getSimpleName() ) );
                 rows.add( new TableRow( 2, classRow, type.getName() ) );
                 rows.add( new TableRow( 2, visibilityRow, descriptor.visibility().toString()
) );
                 rows.add( new TableRow( 2, moduleRow, ( (TransientDetailDescriptor) objectDesciptor
).module() ) );
-                rows.add( new TableRow( 2, layerRow, ( (TransientDetailDescriptor) objectDesciptor
).module().layer() ) );
+                rows.add( new TableRow( 2, layerRow, ( (TransientDetailDescriptor) objectDesciptor
).module()
+                    .layer() ) );
             }
 
             fireTableDataChanged();
@@ -236,7 +220,7 @@ import static org.apache.zest.functional.Iterables.first;
         @Override
         public String getColumnName( int col )
         {
-            return COLUMN_NAMES[ col];
+            return COLUMN_NAMES[ col ];
         }
 
         @Override
@@ -245,5 +229,4 @@ import static org.apache.zest.functional.Iterables.first;
             return rows.size();
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/bd6fbad9/tools/envisage/src/main/java/org/apache/zest/envisage/detail/MethodPane.java
----------------------------------------------------------------------
diff --git a/tools/envisage/src/main/java/org/apache/zest/envisage/detail/MethodPane.java
b/tools/envisage/src/main/java/org/apache/zest/envisage/detail/MethodPane.java
index 0ca082f..ef9e455 100644
--- a/tools/envisage/src/main/java/org/apache/zest/envisage/detail/MethodPane.java
+++ b/tools/envisage/src/main/java/org/apache/zest/envisage/detail/MethodPane.java
@@ -334,7 +334,7 @@ import static org.apache.zest.functional.Iterables.first;
             Icon icon;
             CompositeMethodDetailDescriptor descriptor = (CompositeMethodDetailDescriptor)
value;
 
-            Class compositeClass = first( descriptor.composite().descriptor().types() );
+            Class compositeClass = descriptor.composite().descriptor().types().findFirst().get();
             Class mixinMethodClass = descriptor.descriptor().method().getDeclaringClass();
             if( mixinMethodClass.isAssignableFrom( compositeClass ) )
             {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/bd6fbad9/tools/envisage/src/main/java/org/apache/zest/envisage/detail/ServiceConfigurationPane.java
----------------------------------------------------------------------
diff --git a/tools/envisage/src/main/java/org/apache/zest/envisage/detail/ServiceConfigurationPane.java
b/tools/envisage/src/main/java/org/apache/zest/envisage/detail/ServiceConfigurationPane.java
index f44b1b2..af75be9 100644
--- a/tools/envisage/src/main/java/org/apache/zest/envisage/detail/ServiceConfigurationPane.java
+++ b/tools/envisage/src/main/java/org/apache/zest/envisage/detail/ServiceConfigurationPane.java
@@ -159,11 +159,14 @@ import static org.apache.zest.functional.Iterables.first;
         }
         else if( configDescriptor instanceof CompositeDetailDescriptor )
         {
-            spiDescriptor = ( (ObjectDetailDescriptor) configDescriptor ).descriptor();
+            spiDescriptor = ( (CompositeDetailDescriptor) configDescriptor ).descriptor();
             typeString = "Transient";
         }
-
-        Class<?> type = first( spiDescriptor.types() );
+        else
+        {
+            throw new InternalError( "Unknown Config descriptor type" );
+        }
+        Class<?> type = spiDescriptor.types().findFirst().orElse( null );
         String simpleName = type.getSimpleName();
         nameLabel.setText( "<html><a href='" + simpleName + "'>" + simpleName
+ "</a></html>" );
         classLabel.setText( type.getName() );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/bd6fbad9/tools/envisage/src/main/java/org/apache/zest/envisage/detail/StatePane.java
----------------------------------------------------------------------
diff --git a/tools/envisage/src/main/java/org/apache/zest/envisage/detail/StatePane.java b/tools/envisage/src/main/java/org/apache/zest/envisage/detail/StatePane.java
index 67d0330..ba31e03 100644
--- a/tools/envisage/src/main/java/org/apache/zest/envisage/detail/StatePane.java
+++ b/tools/envisage/src/main/java/org/apache/zest/envisage/detail/StatePane.java
@@ -320,7 +320,7 @@ import static org.apache.zest.functional.Iterables.first;
 
             Icon icon;
             CompositeMethodDetailDescriptor descriptor = (CompositeMethodDetailDescriptor)
value;
-            Class compositeClass = first( descriptor.composite().descriptor().types() );
+            Class compositeClass = descriptor.composite().descriptor().types().findFirst().orElse(
null );
             Class mixinMethodClass = descriptor.descriptor().method().getDeclaringClass();
             if( mixinMethodClass.isAssignableFrom( compositeClass ) )
             {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/bd6fbad9/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceCompositeDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceCompositeDescriptor.java
b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceCompositeDescriptor.java
index 927e7f2..13c80ed 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceCompositeDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceCompositeDescriptor.java
@@ -21,6 +21,7 @@ package org.apache.zest.tools.model.descriptor;
 
 import java.util.LinkedList;
 import java.util.List;
+import java.util.stream.Stream;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.composite.CompositeDescriptor;
 import org.apache.zest.api.service.ImportedServiceDescriptor;
@@ -49,9 +50,9 @@ public class ImportedServiceCompositeDescriptor
     }
 
     @Override
-    public Iterable<Class<?>> mixinTypes()
+    public Stream<Class<?>> mixinTypes()
     {
-        return mixins;
+        return mixins.stream();
     }
 
     @Override
@@ -73,9 +74,9 @@ public class ImportedServiceCompositeDescriptor
     }
 
     @Override
-    public Iterable<Class<?>> types()
+    public Stream<Class<?>> types()
     {
-        return Iterables.cast( Iterables.iterable( importedService.type() ) );
+        return importedService.types();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/zest-java/blob/bd6fbad9/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/MethodFinder.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/MethodFinder.java
b/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/MethodFinder.java
index 23c48cd..8e99c15 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/MethodFinder.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/MethodFinder.java
@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.stream.Stream;
 import org.apache.zest.api.association.Association;
 import org.apache.zest.api.association.ManyAssociation;
 import org.apache.zest.api.association.NamedAssociation;
@@ -51,11 +52,10 @@ public class MethodFinder
         for( CompositeMethodDetailDescriptor descriptor : iter )
         {
             CompositeDescriptor compositeDescriptor = descriptor.composite().descriptor();
-            Iterable<Class<?>> compositeType = compositeDescriptor.types();
             Class<?> mixinMethodClass = descriptor.descriptor().method().getDeclaringClass();
-            for( Class<?> compositeClass : compositeType )
+            compositeDescriptor.types().forEach( mixinType ->
             {
-                if( mixinMethodClass.isAssignableFrom( compositeClass ) )
+                if( mixinMethodClass.isAssignableFrom( mixinType ) )
                 {
                     publicList.add( descriptor );
                 }
@@ -63,7 +63,7 @@ public class MethodFinder
                 {
                     privateList.add( descriptor );
                 }
-            }
+            } );
         }
 
         // combine into one list, with public listed first then private

http://git-wip-us.apache.org/repos/asf/zest-java/blob/bd6fbad9/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/ServiceConfigurationFinder.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/ServiceConfigurationFinder.java
b/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/ServiceConfigurationFinder.java
index dd2b034..00bc63c 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/ServiceConfigurationFinder.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/ServiceConfigurationFinder.java
@@ -145,7 +145,7 @@ class ServiceConfigurationFinder
                 descriptor = ( (CompositeDetailDescriptor) obj ).descriptor();
             }
 
-            if( configType.equals( first( descriptor.types() ) ) )
+            if( configType.equals( descriptor.types().findFirst().orElse( null ) ) )
             {
                 configDescriptor = obj;
                 break;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/bd6fbad9/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/ServiceUsageFinder.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/ServiceUsageFinder.java
b/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/ServiceUsageFinder.java
index 8c73b4d..18cedca 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/ServiceUsageFinder.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/ServiceUsageFinder.java
@@ -36,8 +36,6 @@ import org.apache.zest.tools.model.descriptor.ServiceUsage;
 import org.apache.zest.tools.model.descriptor.TransientDetailDescriptor;
 import org.apache.zest.tools.model.descriptor.ValueDetailDescriptor;
 
-import static org.apache.zest.functional.Iterables.first;
-
 /* package */ class ServiceUsageFinder
 {
     private ServiceDetailDescriptor descriptor;
@@ -138,20 +136,23 @@ import static org.apache.zest.functional.Iterables.first;
             Class<? extends Annotation> clazz = annotation.annotationType();
             if( Uses.class.equals( clazz ) || Service.class.equals( clazz ) )
             {
-                boolean used = false;
-                if( dependencyDescriptor.injectionType().equals( first( this.descriptor.descriptor().types()
) ) )
+                if( dependencyDescriptor.injectionType()
+                    .equals( this.descriptor.descriptor().types().findFirst().orElse( null
) ) )
                 {
                     ServiceUsage usage;
                     if( ownerDescriptor instanceof MixinDetailDescriptor )
                     {
                         MixinDetailDescriptor mixinDescriptor = (MixinDetailDescriptor) ownerDescriptor;
-                        usage = new ServiceUsage( mixinDescriptor.composite(), descriptorField,
mixinDescriptor.composite().module(), mixinDescriptor.composite().module().layer() );
+                        usage = new ServiceUsage( mixinDescriptor.composite(), descriptorField,
mixinDescriptor.composite()
+                            .module(), mixinDescriptor.composite().module().layer() );
                     }
                     else
                     {
                         // assume ObjectDetailDescriptor
                         ObjectDetailDescriptor objectDescriptor = (ObjectDetailDescriptor)
ownerDescriptor;
-                        usage = new ServiceUsage( objectDescriptor, descriptorField, objectDescriptor.module(),
objectDescriptor.module().layer() );
+                        usage = new ServiceUsage( objectDescriptor, descriptorField, objectDescriptor.module(),
objectDescriptor
+                            .module()
+                            .layer() );
                     }
                     usages.add( usage );
                 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/bd6fbad9/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/StateFinder.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/StateFinder.java
b/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/StateFinder.java
index 76a036a..66f422e 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/StateFinder.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/util/StateFinder.java
@@ -43,7 +43,7 @@ public class StateFinder
 
         for( CompositeMethodDetailDescriptor descriptor : iter )
         {
-            Class<?> compositeClass = first( descriptor.composite().descriptor().types()
);
+            Class<?> compositeClass = descriptor.composite().descriptor().types().findFirst().orElse(
null );
             Class<?> mixinMethodClass = descriptor.descriptor().method().getDeclaringClass();
             if( mixinMethodClass.isAssignableFrom( compositeClass ) )
             {


Mime
View raw message