From d7496924cbdf9bb17cf6add7c3097ef00962cd24 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Tue, 12 Aug 2025 10:25:27 +0200 Subject: [PATCH] Add nullability annotations to smoke-test/spring-boot-smoke-test-data-rest See gh-46587 --- .../java/smoketest/data/rest/domain/City.java | 11 ++++++++-- .../smoketest/data/rest/domain/Hotel.java | 11 ++++++++-- .../data/rest/domain/package-info.java | 20 +++++++++++++++++++ .../smoketest/data/rest/package-info.java | 20 +++++++++++++++++++ .../data/rest/service/CitySearchCriteria.java | 9 +-------- .../data/rest/service/package-info.java | 20 +++++++++++++++++++ 6 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/package-info.java create mode 100644 smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/package-info.java create mode 100644 smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/service/package-info.java diff --git a/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/City.java b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/City.java index 44e3ee0367f..fad6e7e3ab5 100644 --- a/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/City.java +++ b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/City.java @@ -23,6 +23,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; import jakarta.persistence.SequenceGenerator; +import org.jspecify.annotations.Nullable; @Entity public class City implements Serializable { @@ -32,26 +33,32 @@ public class City implements Serializable { @Id @SequenceGenerator(name = "city_generator", sequenceName = "city_sequence", initialValue = 23) @GeneratedValue(generator = "city_generator") - private Long id; + private @Nullable Long id; @Column(nullable = false) + @SuppressWarnings("NullAway.Init") private String name; @Column(nullable = false) + @SuppressWarnings("NullAway.Init") private String state; @Column(nullable = false) + @SuppressWarnings("NullAway.Init") private String country; @Column(nullable = false) + @SuppressWarnings("NullAway.Init") private String map; protected City() { } - public City(String name, String country) { + public City(String name, String country, String state, String map) { this.name = name; this.country = country; + this.state = state; + this.map = map; } public String getName() { diff --git a/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/Hotel.java b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/Hotel.java index 39b7316d2c1..c48cf38ccf0 100644 --- a/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/Hotel.java +++ b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/Hotel.java @@ -25,6 +25,7 @@ import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; import jakarta.persistence.SequenceGenerator; import org.hibernate.annotations.NaturalId; +import org.jspecify.annotations.Nullable; @Entity public class Hotel implements Serializable { @@ -34,28 +35,34 @@ public class Hotel implements Serializable { @Id @SequenceGenerator(name = "hotel_generator", sequenceName = "hotel_sequence", initialValue = 28) @GeneratedValue(generator = "hotel_generator") - private Long id; + private @Nullable Long id; @ManyToOne(optional = false) @NaturalId + @SuppressWarnings("NullAway.Init") private City city; @Column(nullable = false) @NaturalId + @SuppressWarnings("NullAway.Init") private String name; @Column(nullable = false) + @SuppressWarnings("NullAway.Init") private String address; @Column(nullable = false) + @SuppressWarnings("NullAway.Init") private String zip; protected Hotel() { } - public Hotel(City city, String name) { + public Hotel(City city, String name, String address, String zip) { this.city = city; this.name = name; + this.address = address; + this.zip = zip; } public City getCity() { diff --git a/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/package-info.java b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/package-info.java new file mode 100644 index 00000000000..beb2fcf068e --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/domain/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.data.rest.domain; + +import org.jspecify.annotations.NullMarked; diff --git a/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/package-info.java b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/package-info.java new file mode 100644 index 00000000000..07c624a4a27 --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.data.rest; + +import org.jspecify.annotations.NullMarked; diff --git a/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/service/CitySearchCriteria.java b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/service/CitySearchCriteria.java index cd1fc66646b..d5cfa777825 100644 --- a/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/service/CitySearchCriteria.java +++ b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/service/CitySearchCriteria.java @@ -24,10 +24,7 @@ public class CitySearchCriteria implements Serializable { private static final long serialVersionUID = 1L; - private String name; - - public CitySearchCriteria() { - } + private final String name; public CitySearchCriteria(String name) { Assert.notNull(name, "'name' must not be null"); @@ -38,8 +35,4 @@ public class CitySearchCriteria implements Serializable { return this.name; } - public void setName(String name) { - this.name = name; - } - } diff --git a/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/service/package-info.java b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/service/package-info.java new file mode 100644 index 00000000000..659dbd315fa --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-data-rest/src/main/java/smoketest/data/rest/service/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.data.rest.service; + +import org.jspecify.annotations.NullMarked;