Skip to content

AutoValue: Adding @Valid attribute to getter results in error #288

@thehereward

Description

@thehereward

We want to annotate a getter on one of our classes with the @Valid annotation to allow cascading validation. AutoValue copies this annotation to the AutoValue class. This results in the following error message:

HV000131: A method return value must not be marked for cascaded validation more than once in a class hierarchy, but the following two methods are marked as such: public my.name.space.Parameters my.name.space.AutoValue_Class.getParameters(), public abstract my.name.space.Parameters my.name.space.Class.getParameters().

We are working around this by applying the annotation to the parameter in the factory method.

e.g.

@JsonCreator
public static Class create(@Valid Parameters parameters){ /* code */ }

It would be nicer if the @Valid were not copied to the autovalue class so we could annotate the getting directly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions