-
Notifications
You must be signed in to change notification settings - Fork 0
JSpecify #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
JSpecify #40
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds JSpecify nullability annotations to the public API of the CTA4J Java SDK to improve type safety and establish clearer nullability contracts. The version is bumped from 3.0.4 to 3.0.5 with the addition of the org.jspecify:jspecify:1.0.0 dependency.
- Added
@NonNullannotations to return types of public API methods inTrainClient,BusClient, and their implementations - Reorganized field declarations in implementation classes to group constants together
- Updated version and changelog to reflect the changes
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 22 comments.
Show a summary per file
| File | Description |
|---|---|
| pom.xml | Bumped version to 3.0.5 and added JSpecify dependency with provided scope |
| CHANGELOG.md | Added release notes for version 3.0.5 documenting the addition of JSpecify annotations |
| src/main/java/com/cta4j/train/client/TrainClient.java | Added @NonNull annotations to method return types and builder methods |
| src/main/java/com/cta4j/train/client/internal/TrainClientImpl.java | Added @NonNull annotations to match interface, reorganized fields to group constants |
| src/main/java/com/cta4j/bus/client/BusClient.java | Added @NonNull annotations to method return types and builder methods |
| src/main/java/com/cta4j/bus/client/internal/BusClientImpl.java | Added @NonNull annotations to match interface, reorganized fields to group constants |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @throws NullPointerException if {@code host} is {@code null} | ||
| */ | ||
| Builder host(String host); | ||
| @NonNull Builder host(String host); |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method parameter host should be annotated with @NonNull to establish a complete nullability contract. The method documentation states it throws NullPointerException if the parameter is null, and the implementation validates this with Objects.requireNonNull. JSpecify annotations should be applied to both return types and parameters for consistency and completeness.
| @NonNull Builder host(String host); | |
| @NonNull Builder host(@NonNull String host); |
|
|
||
| @Override | ||
| public Builder apiKey(String apiKey) { | ||
| public @NonNull Builder apiKey(String apiKey) { |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method parameter apiKey should be annotated with @NonNull to match the interface contract and establish a complete nullability specification. This should be consistent with the interface definition in TrainClient.Builder.
| public @NonNull Builder apiKey(String apiKey) { | |
| public @NonNull Builder apiKey(@NonNull String apiKey) { |
|
|
||
| @Override | ||
| public List<StopArrival> getStopArrivals(String routeId, String stopId) { | ||
| public @NonNull List<StopArrival> getStopArrivals(String routeId, String stopId) { |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method parameters routeId and stopId should be annotated with @NonNull to match the interface contract and establish a complete nullability specification. This should be consistent with the interface definition in BusClient.
| public @NonNull List<StopArrival> getStopArrivals(String routeId, String stopId) { | |
| public @NonNull List<StopArrival> getStopArrivals(@NonNull String routeId, @NonNull String stopId) { |
|
|
||
| @Override | ||
| public Builder host(String host) { | ||
| public @NonNull Builder host(String host) { |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method parameter host should be annotated with @NonNull to match the interface contract and establish a complete nullability specification. This should be consistent with the interface definition in BusClient.Builder.
| public @NonNull Builder host(String host) { | |
| public @NonNull Builder host(@NonNull String host) { |
| * @throws Cta4jException if an error occurs while fetching the data | ||
| */ | ||
| List<String> getDirections(String routeId); | ||
| @NonNull List<String> getDirections(String routeId); |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method parameter routeId should be annotated with @NonNull to establish a complete nullability contract. The method documentation states it throws NullPointerException if the parameter is null, and the implementation validates this with Objects.requireNonNull. JSpecify annotations should be applied to both return types and parameters for consistency and completeness.
| * @throws Cta4jException if an error occurs while fetching the data | ||
| */ | ||
| List<Stop> getStops(String routeId, String direction); | ||
| @NonNull List<Stop> getStops(String routeId, String direction); |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method parameters routeId and direction should be annotated with @NonNull to establish a complete nullability contract. The method documentation states it throws NullPointerException if these parameters are null, and the implementation validates this with Objects.requireNonNull. JSpecify annotations should be applied to both return types and parameters for consistency and completeness.
|
|
||
| @Override | ||
| public Builder host(String host) { | ||
| public @NonNull Builder host(String host) { |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method parameter host should be annotated with @NonNull to match the interface contract and establish a complete nullability specification. This should be consistent with the interface definition in TrainClient.Builder.
| public @NonNull Builder host(String host) { | |
| public @NonNull Builder host(@NonNull String host) { |
|
|
||
| @Override | ||
| public List<Stop> getStops(String routeId, String direction) { | ||
| public @NonNull List<Stop> getStops(String routeId, String direction) { |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method parameters routeId and direction should be annotated with @NonNull to match the interface contract and establish a complete nullability specification. This should be consistent with the interface definition in BusClient.
|
|
||
| @Override | ||
| public Optional<Bus> getBus(String id) { | ||
| public @NonNull Optional<Bus> getBus(String id) { |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method parameter id should be annotated with @NonNull to match the interface contract and establish a complete nullability specification. This should be consistent with the interface definition in BusClient.
| public @NonNull Optional<Bus> getBus(String id) { | |
| public @NonNull Optional<Bus> getBus(@NonNull String id) { |
| * @throws Cta4jException if an error occurs while fetching the data | ||
| */ | ||
| Optional<Bus> getBus(String id); | ||
| @NonNull Optional<Bus> getBus(String id); |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method parameter id should be annotated with @NonNull to establish a complete nullability contract. The method documentation states it throws NullPointerException if the parameter is null, and the implementation validates this with Objects.requireNonNull. JSpecify annotations should be applied to both return types and parameters for consistency and completeness.
No description provided.