From c3e6377896d169410e605e5e27f961936f6a17df Mon Sep 17 00:00:00 2001 From: Jaskeerat Singh Saluja Date: Sun, 4 Aug 2024 20:51:10 +0530 Subject: [PATCH] feat(i114): Java visitor updated for aliased import Signed-off-by: Jaskeerat Singh Saluja --- lib/codegen/fromcto/csharp/csharpvisitor.js | 4 ++-- lib/codegen/fromcto/java/javavisitor.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/codegen/fromcto/csharp/csharpvisitor.js b/lib/codegen/fromcto/csharp/csharpvisitor.js index 37d6456d..0590f538 100644 --- a/lib/codegen/fromcto/csharp/csharpvisitor.js +++ b/lib/codegen/fromcto/csharp/csharpvisitor.js @@ -15,7 +15,7 @@ 'use strict'; -const { ModelUtil } = require('@accordproject/concerto-core'); +const { ModelUtil, ModelFile } = require('@accordproject/concerto-core'); const camelCase = require('camelcase'); const { throwUnrecognizedType } = require('../../../common/util'); @@ -384,7 +384,7 @@ class CSharpVisitor { } else if (!field.isPrimitive()) { let fqn = this.getDotNetNamespaceOfType(field.getFullyQualifiedTypeName(), field.getParent(), parameters); const modelFile = field.getModelFile(); - if (modelFile && modelFile.isImportedType(fieldType)) { + if (modelFile instanceof ModelFile && modelFile.isImportedType(fieldType)) { fieldType = modelFile.getActualImportType(fieldType); } fieldType = `${fqn}${fieldType}`; diff --git a/lib/codegen/fromcto/java/javavisitor.js b/lib/codegen/fromcto/java/javavisitor.js index a3f296cf..182506cc 100644 --- a/lib/codegen/fromcto/java/javavisitor.js +++ b/lib/codegen/fromcto/java/javavisitor.js @@ -14,6 +14,7 @@ 'use strict'; +const { ModelFile } = require('@accordproject/concerto-core'); const EmptyPlugin = require('./emptyplugin'); const ModelUtil = require('@accordproject/concerto-core').ModelUtil; const util = require('util'); @@ -267,9 +268,14 @@ class JavaVisitor { if(field.isArray()) { array = '[]'; } - - const fieldType = this.toJavaType(field.getType()) + array; - + let fieldType = field.getType(); + if (!ModelUtil.isPrimitiveType(fieldType)) { + const modelFile = field.getModelFile(); + if (modelFile instanceof ModelFile && modelFile.isImportedType(fieldType)) { + fieldType = modelFile.getActualImportType(fieldType); + } + } + fieldType = this.toJavaType(fieldType) + array; const fieldName = field.getName(); const getterName = 'get' + this.capitalizeFirstLetter(fieldName); const setterName = 'set' + this.capitalizeFirstLetter(fieldName);