From 8b82ef0121f55ef4f81f7eabd42c4af341f610d6 Mon Sep 17 00:00:00 2001 From: Villu Ruusmann Date: Mon, 26 Jun 2023 12:04:56 +0300 Subject: [PATCH] Improved commit f07dfeb67d --- .../java/org/jpmml/translator/TranslationContext.java | 8 ++++++-- .../translator/regression/RegressionModelTranslator.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pmml-transpiler/src/main/java/org/jpmml/translator/TranslationContext.java b/pmml-transpiler/src/main/java/org/jpmml/translator/TranslationContext.java index a787791..54712c4 100644 --- a/pmml-transpiler/src/main/java/org/jpmml/translator/TranslationContext.java +++ b/pmml-transpiler/src/main/java/org/jpmml/translator/TranslationContext.java @@ -104,7 +104,7 @@ public JClass ref(Class type){ } public JClass genericRef(Class type, Object... typeArgs){ - List arguments = Arrays.stream(typeArgs) + List safeTypeArgs = Arrays.stream(typeArgs) .map(typeArg -> { if(typeArg instanceof Class){ @@ -115,7 +115,11 @@ public JClass genericRef(Class type, Object... typeArgs){ }) .collect(Collectors.toList()); - return ref(type).narrow(arguments); + return genericRef(type, safeTypeArgs); + } + + public JClass genericRef(Class type, List typeArgs){ + return ref(type).narrow(typeArgs); } public JType _ref(Class type){ diff --git a/pmml-transpiler/src/main/java/org/jpmml/translator/regression/RegressionModelTranslator.java b/pmml-transpiler/src/main/java/org/jpmml/translator/regression/RegressionModelTranslator.java index 594a400..e5e6679 100644 --- a/pmml-transpiler/src/main/java/org/jpmml/translator/regression/RegressionModelTranslator.java +++ b/pmml-transpiler/src/main/java/org/jpmml/translator/regression/RegressionModelTranslator.java @@ -516,7 +516,7 @@ public Number apply(FunctionInvocationPredictor tfTerm){ JVar termFrequencyTableVar = (JVar)TextIndexUtil.computeTermFrequencyTable(null, localTextIndex, textIndexVar, termIndicesVar.invoke("keySet"), maxLength, context); - JVar entriesVar = context.declare(context.genericRef(Collection.class, context.ref(Map.Entry.class).narrow(((JClass)termFrequencyTableVar.type()).getTypeParameters())), "entries", termFrequencyTableVar.invoke("entrySet")); + JVar entriesVar = context.declare(context.genericRef(Collection.class, context.genericRef(Map.Entry.class, ((JClass)termFrequencyTableVar.type()).getTypeParameters())), "entries", termFrequencyTableVar.invoke("entrySet")); JBlock block = context.block();