Skip to content

Commit

Permalink
Merge pull request #348 from NaluKit/issue/347
Browse files Browse the repository at this point in the history
#347 fixed
  • Loading branch information
FrankHossfeld authored Jan 5, 2024
2 parents 3de9799 + 4f727ef commit 458d512
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
needs: test
services:
owasp-db:
image: philkohl/owasp-maven-action:latest
image: nalusolutionsgmbh/owasp-maven-action:latest
options: --entrypoint /bin/sh --name owasp-db --hostname owasp-db
steps:
- uses: actions/checkout@v3
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ private void handleErrorPopUpControllerAnnotation(RoundEnvironment roundEnv)
errorPopUpControllerModels.add(errorPopUpControllerModel);
}
// save data in metaModel
if (errorPopUpControllerModels.size() > 0) {
if (!errorPopUpControllerModels.isEmpty()) {
this.metaModel.setErrorPopUpController(errorPopUpControllerModels.get(0));
}
}
Expand Down Expand Up @@ -845,9 +845,12 @@ private MetaModel restore() {
.getResource(StandardLocation.CLASS_OUTPUT,
"",
this.createRelativeFileName());
return gson.fromJson(resource.getCharContent(true)
.toString(),
MetaModel.class);
MetaModel model = gson.fromJson(resource.getCharContent(true)
.toString(),
MetaModel.class);
// clear working lists
model.clearGeneratedConditionList();
return model;
} catch (IOException e) {
// every thing is ok -> no operation
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ private void generateLoadControllers() {
.getSimpleName() +
ProcessorConstants.CREATOR_IMPL));

if (controllerModel.getComposites()
.size() > 0) {
List<String> generatedConditionClassNames = new ArrayList<>();
if (!controllerModel.getComposites()
.isEmpty()) {
controllerModel.getComposites()
.forEach(controllerCompositeModel -> {
if (AlwaysLoadComposite.class.getSimpleName()
Expand All @@ -103,8 +102,7 @@ private void generateLoadControllers() {
.getSimpleName());
} else {
String conditionVariableName;
if (generatedConditionClassNames.contains(controllerCompositeModel.getCondition()
.getClassName())) {
if (this.metaModel.isCondtionAlreadyGenerated(controllerCompositeModel.getCondition())) {
conditionVariableName = this.setFirstCharacterToLowerCase(controllerCompositeModel.getCondition()
.getSimpleName()) +
this.getNameWithVariableCount(controllerCompositeModel.getCondition(),
Expand All @@ -114,7 +112,6 @@ private void generateLoadControllers() {
.getSimpleName()) +
this.getNameWithVariableCount(controllerCompositeModel.getCondition(),
true);

loadComponentsMethodBuilder.addStatement("$T $L = new $T()",
ClassName.get(controllerCompositeModel.getCondition()
.getPackage(),
Expand All @@ -128,8 +125,7 @@ private void generateLoadControllers() {
.addStatement("$L.setContext(super.context)",
conditionVariableName);
// remember generated condition to avoid creating the same class again!
generatedConditionClassNames.add(controllerCompositeModel.getCondition()
.getClassName());
this.metaModel.addGeneratedCondition(controllerCompositeModel.getCondition());
}
loadComponentsMethodBuilder.addStatement("$T.INSTANCE.registerCondition($S, $S, $L)",
ClassName.get(CompositeConditionFactory.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ private void generateLoadShellFactory(TypeSpec.Builder typeSpec) {
.getSimpleName() +
ProcessorConstants.CREATOR_IMPL));

if (shellModel.getComposites()
.size() > 0) {
List<String> generatedConditionClassNames = new ArrayList<>();
if (!shellModel.getComposites()
.isEmpty()) {
shellModel.getComposites()
.forEach(controllerCompositeModel -> {
if (AlwaysLoadComposite.class.getSimpleName()
Expand All @@ -211,8 +210,7 @@ private void generateLoadShellFactory(TypeSpec.Builder typeSpec) {
controllerCompositeModel.getComposite()
.getSimpleName());
} else {
if (!generatedConditionClassNames.contains(controllerCompositeModel.getCondition()
.getClassName())) {
if (!this.metaModel.isCondtionAlreadyGenerated(controllerCompositeModel.getCondition())) {
loadShellFactoryMethodBuilder.addStatement("$T $L = new $T()",
ClassName.get(controllerCompositeModel.getCondition()
.getPackage(),
Expand All @@ -228,8 +226,7 @@ private void generateLoadShellFactory(TypeSpec.Builder typeSpec) {
this.setFirstCharacterToLowerCase(controllerCompositeModel.getCondition()
.getSimpleName()));
// remember generated condition to avoid creating the same class again!
generatedConditionClassNames.add(controllerCompositeModel.getCondition()
.getClassName());
this.metaModel.addGeneratedCondition(controllerCompositeModel.getCondition());
}
loadShellFactoryMethodBuilder.addStatement("$T.INSTANCE.registerCondition($S, $S, $L)",
ClassName.get(CompositeConditionFactory.class),
Expand Down Expand Up @@ -293,9 +290,8 @@ private void generateLoadContollers(TypeSpec.Builder typeSpec) {
.getSimpleName() +
ProcessorConstants.CREATOR_IMPL));

if (controllerModel.getComposites()
.size() > 0) {
List<String> generatedConditionClassNames = new ArrayList<>();
if (!controllerModel.getComposites()
.isEmpty()) {
controllerModel.getComposites()
.forEach(controllerCompositeModel -> {
if (AlwaysLoadComposite.class.getSimpleName()
Expand All @@ -314,8 +310,7 @@ private void generateLoadContollers(TypeSpec.Builder typeSpec) {
controllerCompositeModel.getComposite()
.getSimpleName());
} else {
if (!generatedConditionClassNames.contains(controllerCompositeModel.getCondition()
.getClassName())) {
if (!this.metaModel.isCondtionAlreadyGenerated(controllerCompositeModel.getCondition())) {
loadComponentsMethodBuilder.addStatement("$T $L = new $T()",
ClassName.get(controllerCompositeModel.getCondition()
.getPackage(),
Expand All @@ -331,8 +326,7 @@ private void generateLoadContollers(TypeSpec.Builder typeSpec) {
this.setFirstCharacterToLowerCase(controllerCompositeModel.getCondition()
.getSimpleName()));
// remember generated condition to avoid creating the same class again!
generatedConditionClassNames.add(controllerCompositeModel.getCondition()
.getClassName());
this.metaModel.addGeneratedCondition(controllerCompositeModel.getCondition());
}
loadComponentsMethodBuilder.addStatement("$T.INSTANCE.registerCondition($S, $S, $L)",
ClassName.get(CompositeConditionFactory.class),
Expand Down Expand Up @@ -514,7 +508,6 @@ private void generateLoadPopUpControllers(TypeSpec.Builder typeSpec) {
MethodSpec.Builder loadPopUpControllersMethod = MethodSpec.methodBuilder("loadPopUpControllers")
.addAnnotation(Override.class)
.addModifiers(Modifier.PUBLIC);
List<String> generatedConditionClassNames = new ArrayList<>();
this.metaModel.getPopUpControllers()
.forEach(popUpControllerModel -> {
loadPopUpControllersMethod.addStatement("$T.INSTANCE.registerPopUpController($S, new $L(super.router, super.moduleContext, super.eventBus))",
Expand All @@ -533,8 +526,7 @@ private void generateLoadPopUpControllers(TypeSpec.Builder typeSpec) {
popUpControllerModel.getName());
} else {
String conditionVariableName;
if (generatedConditionClassNames.contains(popUpControllerModel.getCondition()
.getClassName())) {
if (this.metaModel.isCondtionAlreadyGenerated(popUpControllerModel.getCondition())) {
conditionVariableName = this.setFirstCharacterToLowerCase(popUpControllerModel.getCondition()
.getSimpleName()) +
this.getNameWithVariableCount(popUpControllerModel.getCondition(),
Expand All @@ -558,8 +550,7 @@ private void generateLoadPopUpControllers(TypeSpec.Builder typeSpec) {
.addStatement("$L.setContext(super.context)",
conditionVariableName);
// remember generated condition to avoid creating the same class again!
generatedConditionClassNames.add(popUpControllerModel.getCondition()
.getClassName());
this.metaModel.addGeneratedCondition(popUpControllerModel.getCondition());
}
loadPopUpControllersMethod.addStatement("$T.INSTANCE.registerCondition($S, $L)",
ClassName.get(PopUpConditionFactory.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import com.squareup.javapoet.TypeSpec;

import javax.lang.model.element.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PopUpControllerGenerator {
Expand Down Expand Up @@ -56,7 +54,6 @@ void generate() {
MethodSpec.Builder loadPopUpControllerFactoryMethodBuilder = MethodSpec.methodBuilder("loadPopUpControllerFactory")
.addModifiers(Modifier.PUBLIC)
.addAnnotation(Override.class);
List<String> generatedConditionClassNames = new ArrayList<>();
this.metaModel.getPopUpControllers()
.forEach(popUpControllerModel -> {
loadPopUpControllerFactoryMethodBuilder.addStatement("$T.INSTANCE.registerPopUpController($S, new $L(router, context, eventBus))",
Expand All @@ -75,8 +72,7 @@ void generate() {
popUpControllerModel.getName());
} else {
String conditionVariableName;
if (generatedConditionClassNames.contains(popUpControllerModel.getCondition()
.getClassName())) {
if (this.metaModel.isCondtionAlreadyGenerated(popUpControllerModel.getCondition())) {
conditionVariableName = this.setFirstCharacterToLowerCase(popUpControllerModel.getCondition()
.getSimpleName()) +
this.getNameWithVariableCount(popUpControllerModel.getCondition(),
Expand All @@ -100,8 +96,7 @@ void generate() {
.addStatement("$L.setContext(super.context)",
conditionVariableName);
// remember generated condition to avoid creating the same class again!
generatedConditionClassNames.add(popUpControllerModel.getCondition()
.getClassName());
this.metaModel.addGeneratedCondition(popUpControllerModel.getCondition());
}
loadPopUpControllerFactoryMethodBuilder.addStatement("$T.INSTANCE.registerCondition($S, $L)",
ClassName.get(PopUpConditionFactory.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
import com.squareup.javapoet.TypeSpec;

import javax.lang.model.element.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ShellGenerator {
Expand Down Expand Up @@ -96,9 +94,8 @@ private void generateLoadShellFactory() {
.getSimpleName() +
ProcessorConstants.CREATOR_IMPL));

if (shellModel.getComposites()
.size() > 0) {
List<String> generatedConditionClassNames = new ArrayList<>();
if (!shellModel.getComposites()
.isEmpty()) {
shellModel.getComposites()
.forEach(controllerCompositeModel -> {
if (AlwaysLoadComposite.class.getSimpleName()
Expand All @@ -118,8 +115,7 @@ private void generateLoadShellFactory() {
.getSimpleName());
} else {
String conditionVariableName;
if (generatedConditionClassNames.contains(controllerCompositeModel.getCondition()
.getClassName())) {
if (this.metaModel.isCondtionAlreadyGenerated(controllerCompositeModel.getCondition())) {
conditionVariableName = this.setFirstCharacterToLowerCase(controllerCompositeModel.getCondition()
.getSimpleName()) +
this.getNameWithVariableCount(controllerCompositeModel.getCondition(),
Expand All @@ -143,8 +139,7 @@ private void generateLoadShellFactory() {
.addStatement("$L.setContext(super.context)",
conditionVariableName);
// remember generated condition to avoid creating the same class again!
generatedConditionClassNames.add(controllerCompositeModel.getCondition()
.getClassName());
this.metaModel.addGeneratedCondition(controllerCompositeModel.getCondition());
}
loadShellFactoryMethodBuilder.addStatement("$T.INSTANCE.registerCondition($S, $S, $L)",
ClassName.get(CompositeConditionFactory.class),
Expand Down
Loading

0 comments on commit 458d512

Please sign in to comment.