db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1850323 - in /db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates: dbObject/base/ dbObject/base/bean/ peer/impl/base/ recordmapper/base/
Date Fri, 04 Jan 2019 08:22:18 GMT
Author: tv
Date: Fri Jan  4 08:22:18 2019
New Revision: 1850323

URL: http://svn.apache.org/viewvc?rev=1850323&view=rev
Log:
Use Java 7 and 8 language constructs

Modified:
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/bean/objectBeanMethods.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/imports.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildCriteria.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doDelete.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/imports.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/createDbObjectInstanceFromInheritance.vm

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/bean/objectBeanMethods.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/bean/objectBeanMethods.vm?rev=1850323&r1=1850322&r2=1850323&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/bean/objectBeanMethods.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/bean/objectBeanMethods.vm
Fri Jan  4 08:22:18 2019
@@ -86,13 +86,9 @@
           #set ( $beanFieldSetter = $beanFieldElement.getAttribute("setter") )
         if ($foreignField != null)
         {
-            ${beanFieldType} relatedBeans = new ${beanFieldInitializerType}(${foreignField}.size());
-            for ($foreignFieldContainedType related : ${foreignField})
-            {
-                ${foreignBeanClassName} relatedBean = related.getBean(createdBeans);
-                relatedBeans.add(relatedBean);
-            }
-            result.${beanFieldSetter}(relatedBeans);
+            result.${beanFieldSetter}(${foreignField}.stream()
+                    .map(related -> related.getBean(createdBeans))
+                    .collect(Collectors.toList()));
         }
         #end
       #end

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/imports.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/imports.vm?rev=1850323&r1=1850322&r2=1850323&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/imports.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/imports.vm
Fri Jan  4 08:22:18 2019
@@ -32,6 +32,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.List;
+import java.util.stream.Collectors;
 
 #if ($torqueGen.booleanOption("torque.addIntakeRetrievable"))
 import $torqueGen.option("torque.retrievableInterface");

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildCriteria.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildCriteria.vm?rev=1850323&r1=1850322&r2=1850323&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildCriteria.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildCriteria.vm
Fri Jan  4 08:22:18 2019
@@ -100,16 +100,9 @@
     public Criteria buildPkCriteria(
             Collection<${dbObjectClassName}> objects)
     {
-        List<ObjectKey<?>> pks = new ArrayList<ObjectKey<?>>(objects.size());
-        for (${dbObjectClassName} object : objects)
-        {
-            ObjectKey<?> pk = object.getPrimaryKey();
-            if (pk != null)
-            {
-                pks.add(pk);
-            }
-        }
-        return buildCriteria(pks);
+        return buildCriteria(objects.stream()
+                .map(object -> object.getPrimaryKey())
+                .collect(Collectors.toList()));
     }
 
 #end

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doDelete.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doDelete.vm?rev=1850323&r1=1850322&r2=1850323&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doDelete.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doDelete.vm
Fri Jan  4 08:22:18 2019
@@ -95,10 +95,7 @@
     {
         int result = doDelete(buildPkCriteria(objects));
 #if ($torqueGen.booleanOption("torque.om.trackDeleted"))
-        for (${dbObjectClassName} object : objects)
-        {
-            object.setDeleted(true);
-        }
+        objects.forEach(object -> object.setDeleted(true));
 #end
         return result;
     }
@@ -125,10 +122,7 @@
     {
         int result = doDelete(buildPkCriteria(objects), con);
 #if ($torqueGen.booleanOption("torque.om.trackDeleted"))
-        for (${dbObjectClassName} object : objects)
-        {
-            object.setDeleted(true);
-        }
+        objects.forEach(object -> object.setDeleted(true));
 #end
         return result;
     }

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/imports.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/imports.vm?rev=1850323&r1=1850322&r2=1850323&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/imports.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/imports.vm
Fri Jan  4 08:22:18 2019
@@ -51,6 +51,7 @@ import java.util.Map;
 import java.util.HashMap;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.stream.Collectors;
 
 import org.apache.commons.lang.ObjectUtils;
 import org.apache.torque.NoRowsException;

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/createDbObjectInstanceFromInheritance.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/createDbObjectInstanceFromInheritance.vm?rev=1850323&r1=1850322&r2=1850323&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/createDbObjectInstanceFromInheritance.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/createDbObjectInstanceFromInheritance.vm
Fri Jan  4 08:22:18 2019
@@ -66,15 +66,7 @@
                 Class<?> omClass = Class.forName(classKey.toString());
                 $tableField = ($dbObjectClassName) omClass.newInstance();
             }
-            catch (InstantiationException e)
-            {
-                throw new TorqueException(e);
-            }
-            catch (IllegalAccessException e)
-            {
-                throw new TorqueException(e);
-            }
-            catch (ClassNotFoundException e)
+            catch (InstantiationException | IllegalAccessException | ClassNotFoundException
e)
             {
                 throw new TorqueException(e);
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message