You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Properties of types having a no-args constructor or if all of the properties of a constructor have default values, then there is no need to annotate those class with @Dowel annotation or provide a custom PreviewParameterProvider via @ConsiderForDowel, as those class's instance could be easily created by invoking a no-args constructor.
For example :
@Dowel
data classArticle(
valtitle:String,
valstory:String,
valtype:Type,
valmeta:MetaData,
) {
data classType(
valgenre:String = "news",
)
classMetaData {
var hasAffiliateLinks:Boolean=false
}
}
As of now, it is an error to have models like this. It is necessary that both Type and MetaData classes be annotated with @Dowel annotation for Dowel to work.
But it is not really necessary, instances of both Type and MetaData classes can be created without any computational overhead, simply by invoking a no-args constructor (like Type() or MetaData()).
How?
This should be pretty straightforward to achieve given they way ClassRepresentation is structured.
A new type under ParameterSpec could be added for such no-args-constructor declarations. Given that ParameterSpec is a sealed type, the Kotlin compiler itself should yell until all of the cases are handled. And the object construction logic should be straightforward as well as classes can be just instantiated with ().
TODO
Add a new type under ParameterSpec for no-args-constructor declarations
Handle ClassRepresentation mapping
Handle object creation logic
Add tests
Update documentation
The text was updated successfully, but these errors were encountered:
What?
Properties of types having a no-args constructor or if all of the properties of a constructor have default values, then there is no need to annotate those class with
@Dowel
annotation or provide a customPreviewParameterProvider
via@ConsiderForDowel
, as those class's instance could be easily created by invoking a no-args constructor.For example :
As of now, it is an error to have models like this. It is necessary that both
Type
andMetaData
classes be annotated with@Dowel
annotation forDowel
to work.But it is not really necessary, instances of both
Type
andMetaData
classes can be created without any computational overhead, simply by invoking a no-args constructor (likeType()
orMetaData()
).How?
This should be pretty straightforward to achieve given they way
ClassRepresentation
is structured.A new type under
ParameterSpec
could be added for such no-args-constructor declarations. Given thatParameterSpec
is a sealed type, theKotlin
compiler itself should yell until all of the cases are handled. And the object construction logic should be straightforward as well as classes can be just instantiated with()
.TODO
ParameterSpec
for no-args-constructor declarationsClassRepresentation
mappingThe text was updated successfully, but these errors were encountered: