Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions docs/generating-code-from-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ When enabled, the following are added to the generated Java code:

* `@NullMarked` annotations on classes and interfaces so generated types are [non-null by default](https://jspecify.dev/docs/user-guide/#nullmarked)
* `@Nullable` annotations on nullable fields, getters, setters, and constructor parameters
* `Objects.requireNonNull()` validation in the generated builder's `build()` method for non-null fields

!!! note "Where is @NonNull?"
Due to the presence of `@NullMarked` at the type level, we can omit the use of `@NonNull` annotations.
Expand Down Expand Up @@ -296,8 +295,8 @@ public class Event {

public Event build() {
Event result = new Event();
result.id = Objects.requireNonNull(this.id, "id cannot be null");
result.name = Objects.requireNonNull(this.name, "name cannot be null");
result.id = this.id;
result.name = this.name;
result.location = this.location;
result.attendees = this.attendees;
result.organizer = this.organizer;
Expand Down Expand Up @@ -396,9 +395,9 @@ public class Attendee implements Person {

public Attendee build() {
Attendee result = new Attendee();
result.name = Objects.requireNonNull(this.name, "name cannot be null");
result.name = this.name;
result.email = this.email;
result.ticketNumber = Objects.requireNonNull(this.ticketNumber, "ticketNumber cannot be null");
result.ticketNumber = this.ticketNumber;
return result;
}

Expand Down Expand Up @@ -480,7 +479,7 @@ public class EventInput {
public EventInput build() {
EventInput result = new EventInput();
result.id = this.id;
result.name = Objects.requireNonNull(this.name, "name cannot be null");
result.name = this.name;
result.location = this.location;
result.attendeeNames = this.attendeeNames;
return result;
Expand Down