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
I wanted to get thoughts on a new feature where we would be able to specify patterns (regex?) or at the very least a whole package of annotations to include in passAnnotations.
We have a use case where we are adding meta data to our POJOs via annotations and we need this on the class instance.
The issue we are having is that we are adding a long list of classes to passAnnotations to every class.
I looked into InjectAnnotation but these annotations are also used on non-immutables classes and so it's annoying to have 2 types of annotations to use.
We could also setup a meta-annotation for Value.Style but a lot of these classes have other Style attributes and so this gets overridden.
I'm happy to have a go at implementing this but would love opinions on if this is the best route or if there are other alternatives to consider?
Maybe a better option is to have a meta-annotation to add to ours that tells Immutables to pass it automatically?
Thanks,
Harris
The text was updated successfully, but these errors were encountered:
Reading this only now, sorry for delayed feedback. I think we can look into expanding current logic with patterns or alike, passAnnotation is definitely a cumbersome solution. wrt to InjectAnnotation. Can you confirm that it wont work if you apply isPresent=true attribute? It's best to illustrate the idea using example:
// annotations we want to pass/inject,// let's say on accessor (getter) and initializer(builder setter) in this example
@interface Cool {}
@interface Great {}
// InjectAnnotation is repeatable annotation@InjectAnnotation(type = Cool.class, ifPresent = true, target = {Where.ACCESSOR, Where.INITIALIZER})
@InjectAnnotation(type = Great.class, ifPresent = true, target = {Where.ACCESSOR, Where.INITIALIZER})
@interface PassMyAnnotations {}
@ImmutableinterfaceAbc {
@Greatinta();
@CoolStrings();
}
// then put @PassMyAnnotations on either Abc directly or on a whole package.// I don't remember if it will work placed on the meta-annotated style annotation,// but it can be (or can be relatively easy to implement)@PassMyAnnotationspackageabc;
// the expected result would be that we will have// @Great int a() { return this.a; }... @Cool Builder s(String value) { ...// annotation transferred on "Where" targets.// See also tests in the `annotate` module for `ifPresent = true` behavior
Hi,
I wanted to get thoughts on a new feature where we would be able to specify patterns (regex?) or at the very least a whole package of annotations to include in passAnnotations.
We have a use case where we are adding meta data to our POJOs via annotations and we need this on the class instance.
The issue we are having is that we are adding a long list of classes to passAnnotations to every class.
I looked into InjectAnnotation but these annotations are also used on non-immutables classes and so it's annoying to have 2 types of annotations to use.
We could also setup a meta-annotation for Value.Style but a lot of these classes have other Style attributes and so this gets overridden.
I'm happy to have a go at implementing this but would love opinions on if this is the best route or if there are other alternatives to consider?
Maybe a better option is to have a meta-annotation to add to ours that tells Immutables to pass it automatically?
Thanks,
Harris
The text was updated successfully, but these errors were encountered: