That's currently not possible. If there's already a constructor defined, the @Data annotation does not create a new one. You could use an custom Active Annotation to tailor the data class to your needs.
Additional Constructor for Xtend @Data Value Object
-
24-03-2022 - |
Pregunta
How can I add a secondary constructor to a Value Object (annotaded with @Data) in XTend (XText)?
I have tried the following, but it doesnt compile:
@Data class Dependency {
val String groupId;
val String artifactId;
val String version;
val String scope;
new(String groupId, String artifactId, String version) {
this(groupId, artifactId, version, null)
}
}
Solución
Otros consejos
Althought technically not a constructor, you can create factory methods to instantiate your data class in multiple ways.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow