Author: tv Date: Sun Aug 26 10:11:14 2018 New Revision: 1839185 URL: http://svn.apache.org/viewvc?rev=1839185&view=rev Log: A few loop beautifications
Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/bean/base/setterMethodEnd.vm 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/copyMethods.vm db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/setterMethodEnd.vm Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/bean/base/setterMethodEnd.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/bean/base/setterMethodEnd.vm?rev=1839185&r1=1839184&r2=1839185&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/bean/base/setterMethodEnd.vm (original) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/bean/base/setterMethodEnd.vm Sun Aug 26 10:11:14 2018 @@ -63,10 +63,9 @@ // update associated objects in $fieldName if ($fieldName != null) { - for (int i = 0; i < ${fieldName}.size(); i++) + for (${fieldContainedType} element : ${fieldName}) { - ((${fieldContainedType}) ${fieldName}.get(i)) - .${foreignSetterName}(v); + element.${foreignSetterName}(v); } } #end 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=1839185&r1=1839184&r2=1839185&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 Sun Aug 26 10:11:14 2018 @@ -87,9 +87,8 @@ if ($foreignField != null) { ${beanFieldType} relatedBeans = new ${beanFieldInitializerType}(${foreignField}.size()); - for (Iterator<$foreignFieldContainedType> ${foreignField}It = ${foreignField}.iterator(); ${foreignField}It.hasNext(); ) + for ($foreignFieldContainedType related : ${foreignField}) { - ${foreignFieldContainedType} related = ${foreignField}It.next(); ${foreignBeanClassName} relatedBean = related.getBean(createdBeans); relatedBeans.add(relatedBean); } @@ -190,9 +189,8 @@ List<$foreignBeanClassName> relatedBeans = bean.${beanGetter}(); if (relatedBeans != null) { - for (Iterator<$foreignBeanClassName> relatedBeansIt = relatedBeans.iterator(); relatedBeansIt.hasNext(); ) + for ($foreignBeanClassName relatedBean : relatedBeans) { - $foreignBeanClassName relatedBean = relatedBeansIt.next(); ${foreignClassName} related = ${foreignClassName}.create${foreignClassName}(relatedBean, createdObjects); result.${adder}FromBean(related); } Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm?rev=1839185&r1=1839184&r2=1839185&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm (original) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm Sun Aug 26 10:11:14 2018 @@ -169,9 +169,8 @@ $torqueGen.mergepoint("createObjectInsta ## torque.silentDbFetch is set to false if ($columnField != null) { - for (int i = 0; i < ${columnField}.size(); i++) + for (${columnFieldContainedType} obj : ${columnField}) { - ${columnFieldContainedType} obj = ${columnField}.get(i); copyObj.${adder}(obj.copy()); } } Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/setterMethodEnd.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/setterMethodEnd.vm?rev=1839185&r1=1839184&r2=1839185&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/setterMethodEnd.vm (original) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/setterMethodEnd.vm Sun Aug 26 10:11:14 2018 @@ -65,10 +65,9 @@ // update associated objects in $fieldName if ($fieldName != null) { - for (int i = 0; i < ${fieldName}.size(); i++) + for (${fieldContainedType} element : ${fieldName}) { - ((${fieldContainedType}) ${fieldName}.get(i)) - .${foreignSetterName}(v); + element.${foreignSetterName}(v); } } #end --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org For additional commands, e-mail: torque-dev-h...@db.apache.org