ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [24/50] [abbrv] ignite git commit: IGNITE-3236 Array list generation by single way
Date Mon, 20 Jun 2016 02:58:47 GMT
IGNITE-3236 Array list generation by single way


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/af63e89f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/af63e89f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/af63e89f

Branch: refs/heads/ignite-3262
Commit: af63e89f90279591558362644f8bfa5c7bdfcc1a
Parents: ee17ea7
Author: vsisko <vsisko@gridgain.com>
Authored: Tue Jun 7 17:02:31 2016 +0700
Committer: vsisko <vsisko@gridgain.com>
Committed: Tue Jun 7 17:02:31 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/generator/generator-java.js     | 42 ++++++--------------
 1 file changed, 13 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/af63e89f/modules/web-console/src/main/js/generator/generator-java.js
----------------------------------------------------------------------
diff --git a/modules/web-console/src/main/js/generator/generator-java.js b/modules/web-console/src/main/js/generator/generator-java.js
index 155962c..a22a3bf 100644
--- a/modules/web-console/src/main/js/generator/generator-java.js
+++ b/modules/web-console/src/main/js/generator/generator-java.js
@@ -270,12 +270,8 @@ $generatorJava.listProperty = function(res, varName, obj, propName, dataType,
se
 
         res.importClass('java.util.Arrays');
 
-        res.line(varName + '.' + $generatorJava.setterName(propName, setterName) +
-            '(Arrays.asList(' +
-                _.map(val, function(v) {
-                    return $generatorJava.toJavaCode(v, dataType);
-                }).join(', ') +
-            '));');
+        $generatorJava.fxVarArgs(res, varName + '.' + $generatorJava.setterName(propName,
setterName), false,
+            _.map(val, (v) => $generatorJava.toJavaCode(v, dataType)), '(Arrays.asList(',
'))');
 
         res.needEmptyLine = true;
     }
@@ -288,20 +284,22 @@ $generatorJava.listProperty = function(res, varName, obj, propName,
dataType, se
  * @param fx Function name.
  * @param quote Whether to quote arguments.
  * @param args Array with arguments.
+ * @param startBlock Optional start block string.
+ * @param endBlock Optional end block string.
  */
-$generatorJava.fxVarArgs = function(res, fx, quote, args) {
+$generatorJava.fxVarArgs = function(res, fx, quote, args, startBlock = '(', endBlock = ')')
{
     const quoteArg = (arg) => quote ? '"' + arg + '"' : arg;
 
     if (args.length === 1)
-        res.append(fx + '(' + quoteArg(args[0]) + ');');
+        res.append(fx + startBlock + quoteArg(args[0]) + endBlock + ';');
     else {
-        res.startBlock(fx + '(');
+        res.startBlock(fx + startBlock);
 
         const len = args.length - 1;
 
         _.forEach(args, (arg, ix) => res.line(quoteArg(arg) + (ix < len ? ', ' : '')));
 
-        res.endBlock(');');
+        res.endBlock(endBlock + ';');
     }
 };
 
@@ -320,11 +318,8 @@ $generatorJava.arrayProperty = function(res, varName, obj, propName,
setterName)
     if (val && val.length > 0) {
         res.emptyLineIfNeeded();
 
-        res.line(varName + '.' + $generatorJava.setterName(propName, setterName) + '({ '
+
-            _.map(val, function(v) {
-                return 'new ' + res.importClass(v) + '()';
-            }).join(', ') +
-        ' });');
+        $generatorJava.fxVarArgs(res, varName + '.' + $generatorJava.setterName(propName,
setterName), false,
+            _.map(val, (v) => 'new ' + res.importClass(v) + '()'), '({ ', ' });');
 
         res.needEmptyLine = true;
     }
@@ -344,15 +339,8 @@ $generatorJava.multiparamProperty = function(res, varName, obj, propName,
dataTy
     const val = obj[propName];
 
     if (val && val.length > 0) {
-        res.emptyLineIfNeeded();
-
-        res.startBlock(varName + '.' + $generatorJava.setterName(propName, setterName) +
'(');
-
-        _.forEach(val, function(v, ix) {
-            res.append($generatorJava.toJavaCode(dataType === 'class' ? res.importClass(v)
: v, dataType) + (ix < val.length - 1 ? ', ' : ''));
-        });
-
-        res.endBlock(');');
+        $generatorJava.fxVarArgs(res, varName + '.' + $generatorJava.setterName(propName,
setterName), false,
+            _.map(val, (v, ix) => $generatorJava.toJavaCode(dataType === 'class' ? res.importClass(v)
: v, dataType)));
     }
 };
 
@@ -1892,11 +1880,7 @@ $generatorJava.domainModelGeneral = function(domain, res) {
                     types.push('???');
 
                 if ($generatorCommon.isDefinedAndNotEmpty(types)) {
-                    res.startBlock('cache.setIndexedTypes(');
-
-                    res.line(types.join(', '));
-
-                    res.endBlock(');');
+                    $generatorJava.fxVarArgs(res, 'cache.setIndexedTypes', false, types);
                 }
             }
 


Mime
View raw message