-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[FEATURE] Composable Annotations #2294
Comments
I also need this feature: Actually I have a lombok dependency hell on my entities:
which could be simplified by
With such a feature, the following issues could be resolved at once by the user instead of provided by lombok:
@rzwitserloot Please make such a shortcut annotation (=stereotype=composable annotation) possible and relieve us from the lombok dependency hell. |
This has been proposed and discussed several times. Although it would be nice, it is very complicated to implement because it requires resolution. |
... unless we forget about defining the shortcut using annotations (which is ugly and pretends that every annotation can target an annotation). With lombok.config, it'd be probably much simpler (I'd still require the composed annotation to be defined). WDYT? |
Composable annotations would be very useful in the case of enterprise applications. We have a lot of boiler-plate code that could be reduced to a single annotation if we could implement our own combination. It can get hellish annotating every class with the same 3 annotations and taking care of those annotations.
rather than
which takes care of constructors that are required for constructor autowiring and bean initialization. |
@nimo23 Why don't you just use |
@rzwitserloot because
Lombok should provide composable annotations (for example: The benefit is shorter, uncluttered code, DRY (dont repeat yourself) and also that I only need to change one source instead of multiple classes if I decide to change lombok annotations for each of the class. |
期待这个特性的完成, 等的我心慌.... very expect this feature to complete |
It would be nice to be able to compose several Lombok annotations into a custom shortcut annotation, which many people request again and again. It could also be reused for the built-in shortcut annotations like In a second step, this feature would get real super powers, if it could be combined with arbitrary annotations from other packages, i.e. a custom |
@t1 @sidian123 @ariskycode – please tone down the entitled borderline insulting behaviour.
Good that you searched through a bunch of issues and found that this feature has been requested again and again. But evidently you didn't bother to read these issues, because we shoot it down again and again. With reasons. Thus, I'm not sure how I am to take a comment like yours. 'again and again' is a bit judgemental. Perhaps you think Project Lombok owes you this feature? It doesn't, and that kind of entitled attitude is insulting to your friendly neighbourhood open source maintainer. Incredulity that the feature isn't being added? Well, you are your own answer. I did not notice a pull request stapled to your 'again and again' passive aggressive note, and that explains why this feature isn't around yet. It's complicated (feel free to peruse these issues as to why this is quite complicated, it's clear you didn't bother to do this and/or did not understand the issues this feature request needs to solve first), and we lost our magic wands that make features just appear out of thin air. Repeatedly asking for complicated features just clutters the tracker and ticks off the maintainers, so cut that out, not just here, but for all open source projects, and read more of an issue first before chiming in with another me too!!!. Again, that advice goes for all FOSS projects you care to request features for. Input is usually quite welcome, but assume the project maintainers are generally aware of common feature requests, and thus, entertain the thought there might be reasons for why a rather obvious request isn't implemented.
I believe you have a typo there. You wrote "Lombok should", but surely you meant to type "I want".
You're talking to the Project Lombok maintainers. You decided to write this in bold? Jiminy Christmas. Think about that for a moment. That was either a pointless waste of bold or quite rude. I'll give you the benefit of the doubt and consider it a momentary lapse of common sense on your part. Put please, when posting on FOSS lists, take a moment. Hit the 'preview' button if available. Read over what you wrote and think about how it might come across. |
These meta-annotation ideas are, as contributor @janrieke has highlighted, borderline unworkable, but the alternate But, what would it look like? lombok.config is bad at multiline statements, and piling a bunch of lombok annotations on one line seems a bit ugly. Also, I don't think Perhaps we need a completely new aspect to lombok config files, for meta 'annotations'. What if we allow something like this:
This will be a complex parsing bonanza. Laying down some basic ideas on what seems reasonable:
big problem with this idea:
|
Another alternative is to have a The following
is the same as
|
@rzwitserloot In #557 I have linked a proof of concept version. I recently fixed a bunch of problems and my current local version also features default values copying values of the meta annotation to the new added annotation. Before: //conf: lombok.metaAnnotations += @SourceAnnotation(a2={"a2", "b2"}) @TargetAnnotation(a1=<a1>, a2=<a2>)
@SourceAnnotation(a1 = {"a", "b"})
class MetaAnnotationBoundArray {
private String test;
} After: @SourceAnnotation(a1 = {"a", "b"})
@TargetAnnotation(a1 = {"a", "b"}, a2 = {"a2", "b2"})
class MetaAnnotationBoundArray {
private String test;
} I planned to continue it as a seperate project but it obviusly would be better to do it in lombok itself. |
This does not solve any of the stated problems, and is ugly. Let's not dwell on this route any further. |
Oof, yeah, okay, let's close this one and move all debate there. Duplicate of #557. |
from spring documentation
So what I want is the ability to write my own annotation, that is composed of lombok annotations, say for example
@Immutable
now I could add
and it would behave the same as if I had annotated it with
@Value @Builder
,@Value
@Data
could even be implemented in this way and would prevent requests for more of these (well maybe not prevent)Additional context
would solve #2124
The text was updated successfully, but these errors were encountered: