cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgen...@apache.org
Subject [30/50] cayenne-modeler git commit: Switched some loops to streams.
Date Thu, 05 Jan 2017 22:09:38 GMT
Switched some loops to streams.


Project: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/commit/5014a3cb
Tree: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/tree/5014a3cb
Diff: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/diff/5014a3cb

Branch: refs/heads/master
Commit: 5014a3cb121c10da2cc27532918437a22f8cbca3
Parents: 7ca3d46
Author: mrg <blacknext@gmail.com>
Authored: Sat Oct 8 17:24:53 2016 -0400
Committer: mrg <blacknext@gmail.com>
Committed: Sat Oct 8 17:24:53 2016 -0400

----------------------------------------------------------------------
 .../modeler/adapters/DataDomainAdapter.java     | 31 ++------------------
 .../modeler/adapters/DataMapAdapter.java        | 18 +++---------
 .../modeler/adapters/ObjectEntityAdapter.java   |  4 +--
 3 files changed, 8 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/5014a3cb/src/main/java/org/apache/cayenne/modeler/adapters/DataDomainAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/adapters/DataDomainAdapter.java b/src/main/java/org/apache/cayenne/modeler/adapters/DataDomainAdapter.java
index ef4914e..2cafe53 100644
--- a/src/main/java/org/apache/cayenne/modeler/adapters/DataDomainAdapter.java
+++ b/src/main/java/org/apache/cayenne/modeler/adapters/DataDomainAdapter.java
@@ -22,8 +22,6 @@ package org.apache.cayenne.modeler.adapters;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.cayenne.configuration.DataNodeDescriptor;
-import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.modeler.project.CayenneProject;
 
 import javafx.beans.property.BooleanProperty;
@@ -33,12 +31,8 @@ import javafx.beans.property.adapter.JavaBeanStringPropertyBuilder;
 
 public class DataDomainAdapter extends CayennePropertyAdapter // implements AdapterSupport<CayenneProject>
 {
-//    public static final String NAME               = "dataDomainName";
-//    public static final String VALIDATING_OBJECTS = "dataDomainValidatingObjects";
-
     private final CayenneProject cayenneProject;
-//    private BeanPathAdapter<CayenneProject> dataDomainAdapter;
-//    private final ObservableList<DataMapAdapter> dataMapAdapters = FXCollections.emptyObservableList();
+
     private final List<DataMapAdapter> dataMapAdapters = new ArrayList<>(); //FXCollections.emptyObservableList();
     private final List<DataNodeAdapter> dataNodeAdapters = new ArrayList<>();
//FXCollections.emptyObservableList();
 
@@ -49,11 +43,8 @@ public class DataDomainAdapter extends CayennePropertyAdapter // implements
Adap
     {
         this.cayenneProject = cayenneProject;
 
-        for (final DataMap dataMap : cayenneProject.getDataMaps())
-            dataMapAdapters.add(new DataMapAdapter(dataMap));
-
-        for (final DataNodeDescriptor dataNode : cayenneProject.getDataNodes())
-            dataNodeAdapters.add(new DataNodeAdapter(dataNode));
+        cayenneProject.getDataMaps().stream().forEach(dataMap -> dataMapAdapters.add(new
DataMapAdapter(dataMap)));
+        cayenneProject.getDataNodes().stream().forEach(dataNode -> dataNodeAdapters.add(new
DataNodeAdapter(dataNode)));
 
         try
         {
@@ -64,16 +55,8 @@ public class DataDomainAdapter extends CayennePropertyAdapter // implements
Adap
         {
             throw new RuntimeException("Fix the builder.");
         }
-
-//        this.dataDomainAdapter = new BeanPathAdapter<CayenneProject>(cayenneProject);
     }
 
-//    @Override
-//    public BeanPathAdapter<CayenneProject> getBeanPathAdapter()
-//    {
-//        return dataDomainAdapter;
-//    }
-
     public StringProperty nameProperty() { return nameProperty; }
     public String getName() { return nameProperty.get(); }
     public void setName(final String value) { nameProperty.set(value); }
@@ -84,14 +67,6 @@ public class DataDomainAdapter extends CayennePropertyAdapter // implements
Adap
 
     public List<DataMapAdapter> getDataMapAdapters()
     {
-//        if (dataMapAdapters.size() != cayenneProject.getDataMaps().size())
-//        {
-//            for (final DataMap dataMap : cayenneProject.getDataMaps())
-//            {
-//                dataMapAdapters.add(new DataMapAdapter(dataMap));
-//            }
-//        }
-
         return dataMapAdapters;
     }
 

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/5014a3cb/src/main/java/org/apache/cayenne/modeler/adapters/DataMapAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/adapters/DataMapAdapter.java b/src/main/java/org/apache/cayenne/modeler/adapters/DataMapAdapter.java
index 0c1e4f9..b86e5d8 100644
--- a/src/main/java/org/apache/cayenne/modeler/adapters/DataMapAdapter.java
+++ b/src/main/java/org/apache/cayenne/modeler/adapters/DataMapAdapter.java
@@ -22,8 +22,6 @@ package org.apache.cayenne.modeler.adapters;
 import java.util.List;
 
 import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.ObjEntity;
 import org.apache.commons.lang3.ObjectUtils;
 
 import javafx.beans.property.BooleanProperty;
@@ -38,10 +36,7 @@ import javafx.collections.ObservableList;
 public class DataMapAdapter extends CayennePropertyAdapter // implements AdapterSupport<DataMap>
 {
     private final DataMap dataMap;
-//    private BeanPathAdapter<DataMap> dataMapAdapter;
 
-//    private final List<ObjectEntityAdapter>   objectEntityAdapters   = new ArrayList<>();
-//    private final List<DatabaseEntityAdapter> databaseEntityAdapters = new ArrayList<>();
     private final ObservableList<ObjectEntityAdapter>   objectEntityAdapters   = FXCollections.observableArrayList();
     private final ObservableList<DatabaseEntityAdapter> databaseEntityAdapters = FXCollections.observableArrayList();
 
@@ -91,22 +86,17 @@ public class DataMapAdapter extends CayennePropertyAdapter // implements
Adapter
         }
 
         // Create ObjectEntityAdapters for all object entities.
-        for (final ObjEntity objEntity : dataMap.getObjEntities())
-            objectEntityAdapters.add(new ObjectEntityAdapter(objEntity));
+        dataMap.getObjEntities().stream().forEach(objEntity -> objectEntityAdapters.add(new
ObjectEntityAdapter(objEntity)));
 
         // Sort the ObjectEntityAdapters (by their name).
         sortObjectEntities();
 
         // Add change listeners for all ObjectEntityAdapter name changes and automatically
re-sort.
-        for (final ObjectEntityAdapter objectEntityAdapter : objectEntityAdapters)
-            objectEntityAdapter.nameProperty().addListener((observable, oldValue, newValue)
-> sortObjectEntities());
+        objectEntityAdapters.stream().forEach(objectEntityAdapter ->
+            objectEntityAdapter.nameProperty().addListener((observable, oldValue, newValue)
-> sortObjectEntities()));
 
         // Create DatabaseEntityAdapters for all database entities.
-        for (final DbEntity dbEntity : dataMap.getDbEntities())
-            databaseEntityAdapters.add(new DatabaseEntityAdapter(dbEntity));
-
-
-//        this.dataMapAdapter = new BeanPathAdapter<DataMap>(dataMap);
+        dataMap.getDbEntities().stream().forEach(dbEntity -> databaseEntityAdapters.add(new
DatabaseEntityAdapter(dbEntity)));
     }
 
     public StringProperty nameProperty() { return nameProperty; }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/5014a3cb/src/main/java/org/apache/cayenne/modeler/adapters/ObjectEntityAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/adapters/ObjectEntityAdapter.java b/src/main/java/org/apache/cayenne/modeler/adapters/ObjectEntityAdapter.java
index 218b739..4ffa5b2 100644
--- a/src/main/java/org/apache/cayenne/modeler/adapters/ObjectEntityAdapter.java
+++ b/src/main/java/org/apache/cayenne/modeler/adapters/ObjectEntityAdapter.java
@@ -19,7 +19,6 @@
 
 package org.apache.cayenne.modeler.adapters;
 
-import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 
 import javafx.beans.property.BooleanProperty;
@@ -83,8 +82,7 @@ public class ObjectEntityAdapter extends CayennePropertyAdapter // implements
Ad
             throw new RuntimeException("Fix the builder.", e);
         }
 
-        for (final ObjAttribute objAttribute : objectEntity.getAttributes())
-            objectAttributeAdapters.add(new ObjectAttributeAdapter(objAttribute));
+        objectEntity.getAttributes().stream().forEach(objAttribute -> objectAttributeAdapters.add(new
ObjectAttributeAdapter(objAttribute)));
     }
 
     public StringProperty nameProperty() { return nameProperty; }


Mime
View raw message