Skip to content

Inheritable @Optional and evaluation at getter even if field exists #659

@derKrischan

Description

@derKrischan

I'm experimenting with AWS CDK in Java and have to build some Property beans for cloud constructs. Usually it is a mix of mostly predefined options and some options that are later resolved (e.g. IDs of dependent constructs). Therefore I thought it might be worth a try to mix immutable.io with lightbend config and except of one small issue everything works out fine.
When I annotate a property in an immutable bean class with @optional the generated bean class doesn't have the annotation because @optional isn't marked as inheritable. In my mind it should be and I haven't found a reason in the lightbend config discussions why not. (Maybe to harsh but in my mind whenever you override a field in an inherited bean and don't want it to inherit the parent annotations, you already have a code smell.)
the second point belongs to #570 where the @optional at getters is only evaluated if the field does not exist. Even if the field exists and doesn't have the annotation, the corresponding getter should also be evaluated for the annotation.
I will try to deliver a PR as a discussion base.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions