Skip to content

Validation generation and private static final fields #323

@cbarlin

Description

@cbarlin

Hola!

If you have a module-info.java or package-info.java with an @NullMarked JSpecify annotation, and then have a record that looks like this:

@Valid
public record Insect(
  @NotBlank @Size(min = 1, max = 50) String name
) {
  private static final Set<String> FLYING = Set.of("Fly", "Butterfly");
  private static final Set<String> WALKING = Set.of("Ant", "Stick insect");

  public Set<String> associated() {
    if (FLYING.contains(name)) {
      return FLYING;
    }
    return WALKING;
  }
}

The generator errors out with the following:

[ERROR] Non accessible field example.Insect FLYING with no matching getter?
[ERROR] Non accessible field example.Insect WALKING with no matching getter?
[ERROR] Error ValidationAdapter due to nonAccessibleField for example.Insect

Could the generator please ignore private static final fields?

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