Can I specify annotations to be added to Immutable generated classes?

797 Views Asked by At

I have some code using Immutables (https://immutables.github.io/) which generates a ImmutableEntity class with a method like:

public static ImmutableEntity of(EntityId id,
                                  Locale language,
                                  String text)) {
  return validate(new EntityMeldung(id, language, text));
}

but to work with MongoDB POJOs I need that method to have annotations like:

@BsonCreator
public static ImmutableEntity of(@BsonProperty("id") EntityId id,
                                  @BsonProperty("language") Locale language,
                                  @BsonProperty("text") String text)) {
  return validate(new ImmutableEntity(id, language, text));
}

The Entity interface only defines some getters and I'd rather continue to let Immutables generate the ImmutableEntity class and methods like of()

Should I be looking at Annotation Injection?

0

There are 0 best solutions below