From 44d5f2100b1b829bc9fa10248ee841f5d1b28b2d Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Wed, 26 Nov 2025 14:22:44 +0000 Subject: [PATCH] Remove jspecify annotations --- .../petclinic/PetClinicRuntimeHints.java | 4 +-- .../samples/petclinic/model/BaseEntity.java | 7 +++--- .../samples/petclinic/model/NamedEntity.java | 7 +++--- .../samples/petclinic/model/Person.java | 13 +++++----- .../samples/petclinic/model/package-info.java | 3 --- .../samples/petclinic/owner/Owner.java | 25 +++++++++---------- .../petclinic/owner/OwnerController.java | 3 +-- .../samples/petclinic/owner/Pet.java | 13 +++++----- .../petclinic/owner/PetController.java | 5 ++-- .../samples/petclinic/owner/Visit.java | 13 +++++----- .../samples/petclinic/owner/package-info.java | 18 ++++++++++--- .../samples/petclinic/package-info.java | 18 ++++++++++--- .../petclinic/system/package-info.java | 18 ++++++++++--- .../samples/petclinic/vet/Vet.java | 3 +-- .../samples/petclinic/vet/Vets.java | 3 +-- .../samples/petclinic/vet/package-info.java | 18 ++++++++++--- 16 files changed, 102 insertions(+), 69 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/PetClinicRuntimeHints.java b/src/main/java/org/springframework/samples/petclinic/PetClinicRuntimeHints.java index 63b15b49e..4999f4c3c 100644 --- a/src/main/java/org/springframework/samples/petclinic/PetClinicRuntimeHints.java +++ b/src/main/java/org/springframework/samples/petclinic/PetClinicRuntimeHints.java @@ -16,8 +16,6 @@ package org.springframework.samples.petclinic; -import org.jspecify.annotations.Nullable; - import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.samples.petclinic.model.BaseEntity; @@ -27,7 +25,7 @@ import org.springframework.samples.petclinic.vet.Vet; public class PetClinicRuntimeHints implements RuntimeHintsRegistrar { @Override - public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { + public void registerHints(RuntimeHints hints, ClassLoader classLoader) { hints.resources().registerPattern("db/*"); // https://github.com/spring-projects/spring-boot/issues/32654 hints.resources().registerPattern("messages/*"); hints.resources().registerPattern("mysql-default-conf"); diff --git a/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java b/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java index 45255a40a..6babed56d 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java +++ b/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java @@ -21,7 +21,6 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.MappedSuperclass; -import org.jspecify.annotations.Nullable; /** * Simple JavaBean domain object with an id property. Used as a base class for objects @@ -35,13 +34,13 @@ public class BaseEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private @Nullable Integer id; + private Integer id; - public @Nullable Integer getId() { + public Integer getId() { return id; } - public void setId(@Nullable Integer id) { + public void setId(Integer id) { this.id = id; } diff --git a/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java b/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java index 536271d7f..7149c22ed 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java +++ b/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java @@ -18,7 +18,6 @@ package org.springframework.samples.petclinic.model; import jakarta.persistence.Column; import jakarta.persistence.MappedSuperclass; import jakarta.validation.constraints.NotBlank; -import org.jspecify.annotations.Nullable; /** * Simple JavaBean domain object adds a name property to BaseEntity. Used as @@ -33,13 +32,13 @@ public class NamedEntity extends BaseEntity { @Column(name = "name") @NotBlank - private @Nullable String name; + private String name; - public @Nullable String getName() { + public String getName() { return this.name; } - public void setName(@Nullable String name) { + public void setName(String name) { this.name = name; } diff --git a/src/main/java/org/springframework/samples/petclinic/model/Person.java b/src/main/java/org/springframework/samples/petclinic/model/Person.java index 6513b0866..7ee1f0397 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/Person.java +++ b/src/main/java/org/springframework/samples/petclinic/model/Person.java @@ -18,7 +18,6 @@ package org.springframework.samples.petclinic.model; import jakarta.persistence.Column; import jakarta.persistence.MappedSuperclass; import jakarta.validation.constraints.NotBlank; -import org.jspecify.annotations.Nullable; /** * Simple JavaBean domain object representing an person. @@ -30,25 +29,25 @@ public class Person extends BaseEntity { @Column(name = "first_name") @NotBlank - private @Nullable String firstName; + private String firstName; @Column(name = "last_name") @NotBlank - private @Nullable String lastName; + private String lastName; - public @Nullable String getFirstName() { + public String getFirstName() { return this.firstName; } - public void setFirstName(@Nullable String firstName) { + public void setFirstName(String firstName) { this.firstName = firstName; } - public @Nullable String getLastName() { + public String getLastName() { return this.lastName; } - public void setLastName(@Nullable String lastName) { + public void setLastName(String lastName) { this.lastName = lastName; } diff --git a/src/main/java/org/springframework/samples/petclinic/model/package-info.java b/src/main/java/org/springframework/samples/petclinic/model/package-info.java index f878fe8b7..e8982c3d4 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/package-info.java +++ b/src/main/java/org/springframework/samples/petclinic/model/package-info.java @@ -17,7 +17,4 @@ /** * The classes in this package represent utilities used by the domain. */ -@NullMarked package org.springframework.samples.petclinic.model; - -import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/springframework/samples/petclinic/owner/Owner.java b/src/main/java/org/springframework/samples/petclinic/owner/Owner.java index 000c06292..715863cd2 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/Owner.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/Owner.java @@ -33,7 +33,6 @@ import jakarta.persistence.OrderBy; import jakarta.persistence.Table; import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.NotBlank; -import org.jspecify.annotations.Nullable; /** * Simple JavaBean domain object representing an owner. @@ -51,43 +50,43 @@ public class Owner extends Person { @Column(name = "address") @NotBlank - private @Nullable String address; + private String address; @Column(name = "city") @NotBlank - private @Nullable String city; + private String city; @Column(name = "telephone") @NotBlank @Pattern(regexp = "\\d{10}", message = "{telephone.invalid}") - private @Nullable String telephone; + private String telephone; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "owner_id") @OrderBy("name") private final List pets = new ArrayList<>(); - public @Nullable String getAddress() { + public String getAddress() { return this.address; } - public void setAddress(@Nullable String address) { + public void setAddress(String address) { this.address = address; } - public @Nullable String getCity() { + public String getCity() { return this.city; } - public void setCity(@Nullable String city) { + public void setCity(String city) { this.city = city; } - public @Nullable String getTelephone() { + public String getTelephone() { return this.telephone; } - public void setTelephone(@Nullable String telephone) { + public void setTelephone(String telephone) { this.telephone = telephone; } @@ -106,7 +105,7 @@ public class Owner extends Person { * @param name to test * @return the Pet with the given name, or null if no such Pet exists for this Owner */ - public @Nullable Pet getPet(String name) { + public Pet getPet(String name) { return getPet(name, false); } @@ -115,7 +114,7 @@ public class Owner extends Person { * @param id to test * @return the Pet with the given id, or null if no such Pet exists for this Owner */ - public @Nullable Pet getPet(Integer id) { + public Pet getPet(Integer id) { for (Pet pet : getPets()) { if (!pet.isNew()) { Integer compId = pet.getId(); @@ -133,7 +132,7 @@ public class Owner extends Person { * @param ignoreNew whether to ignore new pets (pets that are not saved yet) * @return the Pet with the given name, or null if no such Pet exists for this Owner */ - public @Nullable Pet getPet(String name, boolean ignoreNew) { + public Pet getPet(String name, boolean ignoreNew) { for (Pet pet : getPets()) { String compName = pet.getName(); if (compName != null && compName.equalsIgnoreCase(name)) { diff --git a/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java b/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java index 41b99619e..199ca3611 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java @@ -35,7 +35,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import jakarta.validation.Valid; -import org.jspecify.annotations.Nullable; import org.springframework.web.servlet.mvc.support.RedirectAttributes; @@ -63,7 +62,7 @@ class OwnerController { } @ModelAttribute("owner") - public Owner findOwner(@PathVariable(name = "ownerId", required = false) @Nullable Integer ownerId) { + public Owner findOwner(@PathVariable(name = "ownerId", required = false) Integer ownerId) { return ownerId == null ? new Owner() : this.owners.findById(ownerId) .orElseThrow(() -> new IllegalArgumentException("Owner not found with id: " + ownerId diff --git a/src/main/java/org/springframework/samples/petclinic/owner/Pet.java b/src/main/java/org/springframework/samples/petclinic/owner/Pet.java index 7af9e5b4f..1945f9b67 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/Pet.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/Pet.java @@ -32,7 +32,6 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; import jakarta.persistence.OrderBy; import jakarta.persistence.Table; -import org.jspecify.annotations.Nullable; /** * Simple business object representing a pet. @@ -48,30 +47,30 @@ public class Pet extends NamedEntity { @Column(name = "birth_date") @DateTimeFormat(pattern = "yyyy-MM-dd") - private @Nullable LocalDate birthDate; + private LocalDate birthDate; @ManyToOne @JoinColumn(name = "type_id") - private @Nullable PetType type; + private PetType type; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "pet_id") @OrderBy("date ASC") private final Set visits = new LinkedHashSet<>(); - public void setBirthDate(@Nullable LocalDate birthDate) { + public void setBirthDate(LocalDate birthDate) { this.birthDate = birthDate; } - public @Nullable LocalDate getBirthDate() { + public LocalDate getBirthDate() { return this.birthDate; } - public @Nullable PetType getType() { + public PetType getType() { return this.type; } - public void setType(@Nullable PetType type) { + public void setType(PetType type) { this.type = type; } diff --git a/src/main/java/org/springframework/samples/petclinic/owner/PetController.java b/src/main/java/org/springframework/samples/petclinic/owner/PetController.java index b7274080e..8398e4f13 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/PetController.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/PetController.java @@ -34,7 +34,6 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import jakarta.validation.Valid; -import org.jspecify.annotations.Nullable; import org.springframework.web.servlet.mvc.support.RedirectAttributes; @@ -73,8 +72,8 @@ class PetController { } @ModelAttribute("pet") - public @Nullable Pet findPet(@PathVariable("ownerId") int ownerId, - @PathVariable(name = "petId", required = false) @Nullable Integer petId) { + public Pet findPet(@PathVariable("ownerId") int ownerId, + @PathVariable(name = "petId", required = false) Integer petId) { if (petId == null) { return new Pet(); diff --git a/src/main/java/org/springframework/samples/petclinic/owner/Visit.java b/src/main/java/org/springframework/samples/petclinic/owner/Visit.java index 7259fab9f..085cd2849 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/Visit.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/Visit.java @@ -24,7 +24,6 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Table; import jakarta.validation.constraints.NotBlank; -import org.jspecify.annotations.Nullable; /** * Simple JavaBean domain object representing a visit. @@ -38,10 +37,10 @@ public class Visit extends BaseEntity { @Column(name = "visit_date") @DateTimeFormat(pattern = "yyyy-MM-dd") - private @Nullable LocalDate date; + private LocalDate date; @NotBlank - private @Nullable String description; + private String description; /** * Creates a new instance of Visit for the current date @@ -50,19 +49,19 @@ public class Visit extends BaseEntity { this.date = LocalDate.now(); } - public @Nullable LocalDate getDate() { + public LocalDate getDate() { return this.date; } - public void setDate(@Nullable LocalDate date) { + public void setDate(LocalDate date) { this.date = date; } - public @Nullable String getDescription() { + public String getDescription() { return this.description; } - public void setDescription(@Nullable String description) { + public void setDescription(String description) { this.description = description; } diff --git a/src/main/java/org/springframework/samples/petclinic/owner/package-info.java b/src/main/java/org/springframework/samples/petclinic/owner/package-info.java index ef080a0d6..9e2a3a4ec 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/package-info.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/package-info.java @@ -1,4 +1,16 @@ -@NullMarked +/* + * Copyright 2012-2025 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. + */ package org.springframework.samples.petclinic.owner; - -import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/springframework/samples/petclinic/package-info.java b/src/main/java/org/springframework/samples/petclinic/package-info.java index c8261d8f0..8c54417d9 100644 --- a/src/main/java/org/springframework/samples/petclinic/package-info.java +++ b/src/main/java/org/springframework/samples/petclinic/package-info.java @@ -1,4 +1,16 @@ -@NullMarked +/* + * Copyright 2012-2025 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. + */ package org.springframework.samples.petclinic; - -import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/springframework/samples/petclinic/system/package-info.java b/src/main/java/org/springframework/samples/petclinic/system/package-info.java index 25da176d0..7d1468177 100644 --- a/src/main/java/org/springframework/samples/petclinic/system/package-info.java +++ b/src/main/java/org/springframework/samples/petclinic/system/package-info.java @@ -1,4 +1,16 @@ -@NullMarked +/* + * Copyright 2012-2025 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. + */ package org.springframework.samples.petclinic.system; - -import org.jspecify.annotations.NullMarked; diff --git a/src/main/java/org/springframework/samples/petclinic/vet/Vet.java b/src/main/java/org/springframework/samples/petclinic/vet/Vet.java index c8bd549d5..fb2bd71ee 100644 --- a/src/main/java/org/springframework/samples/petclinic/vet/Vet.java +++ b/src/main/java/org/springframework/samples/petclinic/vet/Vet.java @@ -31,7 +31,6 @@ import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.Table; import jakarta.xml.bind.annotation.XmlElement; -import org.jspecify.annotations.Nullable; /** * Simple JavaBean domain object representing a veterinarian. @@ -48,7 +47,7 @@ public class Vet extends Person { @ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"), inverseJoinColumns = @JoinColumn(name = "specialty_id")) - private @Nullable Set specialties; + private Set specialties; protected Set getSpecialtiesInternal() { if (this.specialties == null) { diff --git a/src/main/java/org/springframework/samples/petclinic/vet/Vets.java b/src/main/java/org/springframework/samples/petclinic/vet/Vets.java index a3292927a..634cad773 100644 --- a/src/main/java/org/springframework/samples/petclinic/vet/Vets.java +++ b/src/main/java/org/springframework/samples/petclinic/vet/Vets.java @@ -20,7 +20,6 @@ import java.util.List; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; -import org.jspecify.annotations.Nullable; /** * Simple domain object representing a list of veterinarians. Mostly here to be used for @@ -31,7 +30,7 @@ import org.jspecify.annotations.Nullable; @XmlRootElement public class Vets { - private @Nullable List vets; + private List vets; @XmlElement public List getVetList() { diff --git a/src/main/java/org/springframework/samples/petclinic/vet/package-info.java b/src/main/java/org/springframework/samples/petclinic/vet/package-info.java index 6fbc63698..544db4c7c 100644 --- a/src/main/java/org/springframework/samples/petclinic/vet/package-info.java +++ b/src/main/java/org/springframework/samples/petclinic/vet/package-info.java @@ -1,4 +1,16 @@ -@NullMarked +/* + * Copyright 2012-2025 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. + */ package org.springframework.samples.petclinic.vet; - -import org.jspecify.annotations.NullMarked;