-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The newly introduced support for lenses generation for sealed classes or interfaces (see #876) must allow to configure whether some property should be picked for lens generation or not. This heavily depends on the implementation of those. The default case is to pick a property, but sometimes a property will not be implemented as constructor property inside the child data class. For such cases it is now possible to mark such properties with the `@NoLens` annotation inside the sealed type. Such marked properties will get ignored by the lens generator, so no delegating lens will be created. Beware that this annotation is not evaluated inside the constructor of data classes! Imagine the following example to see `@NoLens` in action: ```kotlin @lenses sealed class Framework { // Ignore this property for delegating lens generation. // The property is considered to be constant for all objects, // see data class below @nolens val ignore: String abstract val foo: String companion object } data class Fritz2 ( override val foo: String, ) : Framework { // not part of the "data", so not possible to change at copy! // Because of that, we cannot define any valid lens in the sealed base, // so we must mark it to exclude it for lens creation! override val ignore: String = "Fritz2" } ```
- Loading branch information
christian.hausknecht
committed
Sep 9, 2024
1 parent
029fa6a
commit 828488d
Showing
3 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters