Skip to content

Commit

Permalink
The trivial recovery creates an artificial Object class if it cannot …
Browse files Browse the repository at this point in the history
…find the model for the Object class (#23).
  • Loading branch information
HansMartinA committed Jul 30, 2023
1 parent e1b27f7 commit 5242d48
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,18 @@ private void initArtificialResource() {
}

private tools.mdsd.jamopp.model.java.classifiers.Class findObjectClass() {
return this.set.getResources().stream().filter(resource -> !resource.getContents().isEmpty()
var optionalResult = this.set.getResources().stream().filter(resource -> !resource.getContents().isEmpty()
&& resource.getContents().get(0) instanceof CompilationUnit)
.map(resource -> (CompilationUnit) resource.getContents().get(0))
.filter(cu -> cu.getNamespaces().size() == 2 && cu.getNamespaces().get(0).equals("java")
&& cu.getNamespaces().get(1).equals("lang") && cu.getName().equals("Object"))
.map(cu -> (tools.mdsd.jamopp.model.java.classifiers.Class) cu.getClassifiers().get(0)).findFirst().get();
.map(cu -> (tools.mdsd.jamopp.model.java.classifiers.Class) cu.getClassifiers().get(0)).findFirst();
if (optionalResult.isPresent()) {
return optionalResult.get();
}
tools.mdsd.jamopp.model.java.classifiers.Class ownObjectClass = ClassifiersFactory.eINSTANCE.createClass();
ownObjectClass.setName("Object");
this.artificialCU.getClassifiers().add(ownObjectClass);
return ownObjectClass;
}
}

0 comments on commit 5242d48

Please sign in to comment.