joelittlejohn / jsonschema2pojo

Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc
http://www.jsonschema2pojo.org
Apache License 2.0
6.24k stars 1.66k forks source link

How to force generate @Nullable/@Nonnull for getters/setters? #1512

Open marcelmatula opened 1 year ago

marcelmatula commented 1 year ago

example how it is generated:

public class Result {

    @Nullable
    @JsonProperty("ID")
    private Long id;

    @JsonProperty("ID")
    public Long getId() {
        return this.id;
    }
    @JsonProperty("ID")
    public void setId(Long id) {
        this.id = id;
    }
}

and below is what I want to generate in order to catch potentional NPE issues during compile time.

public class Result {

    @Nullable
    @JsonProperty("ID")
    private Long id;

    @JsonProperty("ID")
    @Nullable
    public Long getId() {
        return this.id;
    }

    @JsonProperty("ID")
    public void setId(@Nullable Long id) {
        this.id = id;
    }

}

and same for @Nonnull getters/setters

unkish commented 1 year ago

Hi

I'm afraid it's currently not supported, there is a similar request #897 for jsr303