Skip to content

Commit

Permalink
Merge pull request #361 from klee-contrib/revert-353-gideruette/issue352
Browse files Browse the repository at this point in the history
Revert "[JPA] Dans les fieldsEnum, exposer le getter directement"
  • Loading branch information
gideruette authored Jun 18, 2024
2 parents 0b5012a + 414100f commit 3293bd8
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions TopModel.Generator.Jpa/JpaModelGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,41 +394,27 @@ private void WriteFieldsEnum(JavaWriter fw, Class classe, string tag)
name = prop.Name.ToConstantCase();
}

var propertyName = Config.UseJdbc ? prop.NameCamel : prop.NameByClassCamel;
var getterPrefix = Config.GetType(prop, Classes, true) == "boolean" ? "is" : "get";
var javaType = Config.GetType(prop, useClassForAssociation: classe.IsPersistent && !Config.UseJdbc);
javaType = javaType.Split("<")[0];
return $" {name}({javaType}.class, {classe.NamePascal}::{propertyName.ToFirstUpper().WithPrefix(getterPrefix)})";
javaType = javaType.Split("<").First();
return $" {name}({javaType}.class)";
});

fw.WriteLine(string.Join(", //\n", props) + ";");
fw.WriteLine();

fw.WriteLine(2, "private Class<?> type;");

fw.WriteLine();

fw.AddImport("java.util.function.Function");
fw.WriteLine(2, $@"private Function<{classe.NamePascal}, ?> getter;");

fw.WriteLine(2, "private Class<?> type;");
fw.WriteLine();

fw.WriteLine(2, $@"private <T> Fields(Class<T> type, Function<{classe.NamePascal}, T> getter) {{");
fw.WriteLine(2, "private Fields(Class<?> type) {");
fw.WriteLine(3, "this.type = type;");
fw.WriteLine(3, "this.getter = getter;");
fw.WriteLine(2, "}");

fw.WriteLine();

fw.WriteLine(2, "public Class<?> getType() {");
fw.WriteLine(3, "return this.type;");
fw.WriteLine(2, "}");

fw.WriteLine();

fw.WriteLine(2, @$"public Function<{classe.NamePascal}, ?> getter() {{");
fw.WriteLine(3, "return this.getter;");
fw.WriteLine(2, "}");

fw.WriteLine(1, "}");
}

Expand Down

0 comments on commit 3293bd8

Please sign in to comment.