1

I am using Immutables-value for defining my POJO. And when it generates the Immutable* class, it has the @Generated annotation at the top. Is there any way I could disable it?

I checked in their codebase: https://github.com/immutables/immutables/blob/master/value-annotations/src/org/immutables/value/Generated.java#L22-L27

It is mentioned here that it can be disabled by : Style#allowedClasspathAnnotations()

I used it on top of POJO interface like this:

@Value.Style(allowedClasspathAnnotations = {org.immutables.value.Generated.class})

But still I am getting the @Generated annotation on top of my generated class. Any idea how can I do this?

hatellla
  • 4,796
  • 8
  • 49
  • 101

1 Answers1

0

@Style's allowedClasspathAnnotations attribute whitelists the annotations you included there (Rather than blacklisting them). See here.

So if you want to only disable org.immutables.value.Generated you should instead do something like:

@Value.Style(allowedClasspathAnnotations = {
  javax.annotation.concurrent.Immutable,
  javax.annotation.ParametersAreNonnullByDefault,
  javax.annotation.CheckReturnValue,
  edu.umd.cs.findbugs.annotations.SuppressFBWarnings,
  com.google.errorprone.annotations.Var,
  com.google.errorprone.annotations.Immutable
})

To whitelist the annotations you want to keep.

imTachu
  • 3,759
  • 4
  • 29
  • 56