|
27 | 27 | import com.regnosys.rosetta.common.util.ClassPathUtils; |
28 | 28 | import com.regnosys.rosetta.common.util.UrlUtils; |
29 | 29 | import com.regnosys.rosetta.generator.java.types.JavaTypeTranslator; |
| 30 | +import com.regnosys.rosetta.generator.java.types.RGeneratedJavaClass; |
30 | 31 | import com.regnosys.rosetta.rosetta.RosettaModel; |
31 | 32 | import com.regnosys.rosetta.rosetta.RosettaReport; |
32 | 33 | import com.regnosys.rosetta.transgest.ModelLoader; |
@@ -228,17 +229,19 @@ private List<RosettaModel> getModels(String classpathDir) { |
228 | 229 | this.getClass().getClassLoader()) |
229 | 230 | .stream() |
230 | 231 | .map(UrlUtils::toUrl) |
231 | | - .collect(Collectors.toList()); |
| 232 | + .toList(); |
232 | 233 | List<RosettaModel> models = modelLoader.loadRosettaModels(urls.stream()); |
233 | 234 | if (models.size() <= 2) { |
234 | 235 | throw new IllegalArgumentException("No model rosetta files found. Only found basic types and annotations rosetta files."); |
235 | 236 | } |
236 | 237 | return models; |
237 | 238 | } |
238 | 239 |
|
| 240 | + @SuppressWarnings("unchecked") |
239 | 241 | private LabelProvider getLabelProvider(RFunction rFunction) { |
240 | 242 | try { |
241 | | - Class<? extends LabelProvider> labelProviderClass = javaTypeTranslator.toLabelProviderJavaClass(rFunction).loadClass(getClass().getClassLoader()); |
| 243 | + RGeneratedJavaClass<? extends LabelProvider> labelProviderJavaClass = javaTypeTranslator.toLabelProviderJavaClass(rFunction); |
| 244 | + Class<? extends LabelProvider> labelProviderClass = (Class<? extends LabelProvider>) getClass().getClassLoader().loadClass(labelProviderJavaClass.getCanonicalName().toString()); |
242 | 245 | return injector.getInstance(labelProviderClass); |
243 | 246 | } catch (ClassNotFoundException e) { |
244 | 247 | throw new RuntimeException(e); |
@@ -278,8 +281,7 @@ private void collectTypeAttributes(RDataType parentDataType, RosettaPath path, L |
278 | 281 | .map(p -> p.newSubPath(pathElement)) |
279 | 282 | .orElse(RosettaPath.createPath(pathElement)); |
280 | 283 | RType attributeType = attribute.getRMetaAnnotatedType().getRType(); |
281 | | - if (attributeType instanceof RDataType) { |
282 | | - RDataType childDataType = (RDataType) attributeType; |
| 284 | + if (attributeType instanceof RDataType childDataType) { |
283 | 285 | // collect attributes for child type |
284 | 286 | collectTypeAttributes(childDataType, attributePath, labelProvider, visitor); |
285 | 287 | } else { |
|
0 commit comments