Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accolades sur le "if liste null". #395

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion TopModel.Generator.Jpa/JpaModelPropertyGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ public void WriteGetter(JavaWriter fw, Class classe, string tag, IProperty prope
var type = _config.GetType(ap, _classes, useClassForAssociation: useClassForAssociation).Split('<').First();
if (_newableTypes.TryGetValue(type, out var newableType))
{
fw.WriteLine(indentLevel + 1, $"if(this.{propertyName} == null)");
fw.WriteLine(indentLevel + 1, $"if(this.{propertyName} == null) {{");
fw.AddImport($"java.util.{newableType}");
fw.WriteLine(indentLevel + 2, $"this.{propertyName} = new {newableType}<>();");
fw.WriteLine(indentLevel + 1, $"}}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ public String getLibelle() {
* @return value of {@link topmodel.jpa.sample.demo.entities.securite.profil.Profil#droits droits}.
*/
public List<Droit> getDroits() {
if(this.droits == null)
if(this.droits == null) {
this.droits = new ArrayList<>();
}
return this.droits;
}

Expand Down
2 changes: 1 addition & 1 deletion samples/model/jpa.topmodel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

version: 2.1.2
custom:
../../../TopModel.Generator.Jpa: 3df4f5992b92ce79d5bfddf465926bd2
../../../TopModel.Generator.Jpa: e556f6e7c4df49eb72b9ac467a259be9
generatedFiles:
- ../generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/profil/ProfilClient.java
- ../generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/utilisateur/UtilisateurClient.java
Expand Down
Loading