diff --git a/.editorconfig b/.editorconfig
index 31325f8..83142a7 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -9,6 +9,10 @@ indent_size = 4
indent_style = space
insert_final_newline = true
+[*.java]
+ij_java_class_count_to_use_import_on_demand = 999
+ij_java_names_count_to_use_import_on_demand = 999
+
[*.{bat,cmd}]
end_of_line = crlf
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 848cd16..fba6eca 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -6,7 +6,7 @@ on:
- '*'
pull_request:
branches:
- - $default-branch
+ - '*'
jobs:
build:
diff --git a/LICENSE_HEADER.txt b/LICENSE_HEADER.txt
new file mode 100644
index 0000000..d95ab40
--- /dev/null
+++ b/LICENSE_HEADER.txt
@@ -0,0 +1,13 @@
+Copyright ${year} 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
+
+ http://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.
\ No newline at end of file
diff --git a/README.md b/README.md
index e31bc4c..6a83ab5 100644
--- a/README.md
+++ b/README.md
@@ -166,7 +166,7 @@ public class ExampleConfiguration {
### Build Requirements
-* Java 17 or above to build. The release jars are compiled to Java 8 bytecode. Integration tests are compiled to Java 17 bytecode.
+* Java 17 or above to build and use.
To build:
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 2dec21b..b33d72c 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -1,8 +1,14 @@
# Release Notes
-## 0.7.0-SNAPSHOT
+## 1.0.0-SNAPSHOT
Released N/A
+- Breaking change
+- Updated to support Spring 6.x and Spring Boot 3.x. This brings with it a minimum Java version of 17. With the Spring
+ upgrade comes a switch to the Jakara EE Servlet API instead of Java EE.
+- Update build to Gradle 8.9
+- Added support for ErrorProne and NullAway for compile time checks of nullability.
+
## 0.6.0
Released 2023-12-01
diff --git a/build.gradle.kts b/build.gradle.kts
index 7cfa1e7..761eb9e 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -6,10 +6,8 @@ plugins {
}
allprojects {
- apply(plugin = "com.mattbertolini.buildlogic.project-conventions")
-
group = "com.mattbertolini"
- version = "0.7.0-SNAPSHOT"
+ version = "1.0.0-SNAPSHOT"
}
val rootJacocoDir = "reports/jacoco/testCodeCoverageReport"
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index 876c922..cbccb00 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -3,5 +3,11 @@ plugins {
}
repositories {
+ gradlePluginPortal()
mavenCentral()
}
+
+dependencies {
+ implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.0.1")
+ implementation("gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.16.1")
+}
diff --git a/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/error-prone.gradle.kts b/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/error-prone.gradle.kts
new file mode 100644
index 0000000..debf80f
--- /dev/null
+++ b/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/error-prone.gradle.kts
@@ -0,0 +1,33 @@
+package com.mattbertolini.buildlogic
+
+import net.ltgt.gradle.errorprone.CheckSeverity
+import net.ltgt.gradle.errorprone.errorprone
+
+plugins {
+ id("net.ltgt.errorprone")
+}
+
+val libsCatalog = versionCatalogs.named("libs")
+val errorProneCore = libsCatalog.findLibrary("errorProneCore").orElseThrow()
+val errorProneAnnotations = libsCatalog.findLibrary("errorProneAnnotations").orElseThrow();
+val nullAway = libsCatalog.findLibrary("nullAway").orElseThrow()
+val nullAwayAnnotations = libsCatalog.findLibrary("nullAwayAnnotations").orElseThrow()
+
+dependencies {
+ errorprone(errorProneCore)
+ errorprone(nullAway)
+}
+
+project.extensions.getByType().configureEach {
+ dependencies.add(compileOnlyConfigurationName, errorProneAnnotations)
+ dependencies.add(compileOnlyConfigurationName, nullAwayAnnotations)
+}
+
+tasks.withType().configureEach {
+ options.isFork = true
+ options.errorprone {
+ disableWarningsInGeneratedCode.set(true)
+ check("NullAway", CheckSeverity.ERROR)
+ option("NullAway:AnnotatedPackages", "com.mattbertolini")
+ }
+}
diff --git a/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/java-conventions.gradle.kts b/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/java-conventions.gradle.kts
index fbc4ecd..9724867 100644
--- a/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/java-conventions.gradle.kts
+++ b/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/java-conventions.gradle.kts
@@ -3,6 +3,8 @@ package com.mattbertolini.buildlogic
plugins {
java
jacoco
+ id("com.mattbertolini.buildlogic.project-conventions")
+ id("com.mattbertolini.buildlogic.error-prone")
}
val versionCatalog = versionCatalogs.named("libs")
@@ -13,10 +15,6 @@ java {
}
}
-tasks.named("compileJava").configure {
- options.release.set(8)
-}
-
testing {
suites {
named("test").configure {
@@ -34,30 +32,25 @@ tasks.named("jar").configure {
}
}
-val springVersion: String = versionCatalog.findVersion("spring").orElseThrow().toString()
-val springBootVersion: String = versionCatalog.findVersion("springBoot").orElseThrow().toString()
-
val javadocLinks = arrayOf(
- "https://docs.oracle.com/javase/8/docs/api/",
- "https://docs.oracle.com/javaee/7/api/",
- "https://docs.spring.io/spring-framework/docs/$springVersion/javadoc-api/",
- "https://docs.spring.io/spring-boot/docs/$springBootVersion/api/"
+ "https://docs.oracle.com/en/java/javase/17/docs/api",
+ "https://jakarta.ee/specifications/platform/11/apidocs/",
+ "https://docs.spring.io/spring-framework/docs/current/javadoc-api/",
+ "https://docs.spring.io/spring-boot/api/java/"
)
tasks.named("javadoc").configure {
options {
this as StandardJavadocDocletOptions
- source = "8"
+ source = "17"
links(*javadocLinks)
addStringOption("Xdoclint:none", "-quiet")
- if (java.toolchain.languageVersion.get().asInt() >= 9) {
- addBooleanOption("html5", true)
- }
+ addBooleanOption("html5", true)
}
}
val jacocoVersion: String = versionCatalog.findVersion("jacoco").orElseThrow().toString()
-configure {
+jacoco {
toolVersion = jacocoVersion
}
@@ -69,4 +62,6 @@ tasks.named("jacocoTestReport").configure {
}
}
-tasks.test { finalizedBy(tasks.jacocoTestReport) }
+tasks.named("test").configure {
+ finalizedBy(tasks.named("jacocoTestReport"))
+}
diff --git a/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/java-library.gradle.kts b/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/java-library.gradle.kts
index 96acfd0..271e920 100644
--- a/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/java-library.gradle.kts
+++ b/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/java-library.gradle.kts
@@ -2,6 +2,5 @@ package com.mattbertolini.buildlogic
plugins {
`java-library`
+ id("com.mattbertolini.buildlogic.java-conventions")
}
-
-apply(plugin = "com.mattbertolini.buildlogic.java-conventions")
diff --git a/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/license-conventions.gradle.kts b/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/license-conventions.gradle.kts
new file mode 100644
index 0000000..6c33189
--- /dev/null
+++ b/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/license-conventions.gradle.kts
@@ -0,0 +1,13 @@
+package com.mattbertolini.buildlogic
+
+import java.time.LocalDate
+
+plugins {
+ id("com.github.hierynomus.license")
+}
+
+license {
+ mapping("java", "SLASHSTAR_STYLE")
+ header = isolated.rootProject.projectDirectory.file("LICENSE_HEADER.txt").asFile
+ ext.set("year", LocalDate.now().year)
+}
diff --git a/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/project-conventions.gradle.kts b/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/project-conventions.gradle.kts
index a7b73b0..f1cc10b 100644
--- a/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/project-conventions.gradle.kts
+++ b/buildSrc/src/main/kotlin/com/mattbertolini/buildlogic/project-conventions.gradle.kts
@@ -1,5 +1,9 @@
package com.mattbertolini.buildlogic
+//plugins {
+// id("com.mattbertolini.buildlogic.license-conventions")
+//}
+
// Configuring archive tasks to have repeatable builds
tasks.withType().configureEach {
isReproducibleFileOrder = true
diff --git a/docs/build.gradle.kts b/docs/build.gradle.kts
index 82b5cb0..330fa0c 100644
--- a/docs/build.gradle.kts
+++ b/docs/build.gradle.kts
@@ -12,7 +12,8 @@ configurations {
dependencies {
implementation(project(":spring-webmvc-annotated-data-binder"))
implementation(project(":spring-webflux-annotated-data-binder"))
- implementation(libs.javaxServletApi) // Version defined in Spring BOM file
+ implementation(libs.jakartaServletApi) // Version defined in Spring BOM file
+ compileOnly(libs.findbugsJsr305)
add("asciidoctorExt", libs.springAsciidoctorExtBlockSwitch)
@@ -20,7 +21,10 @@ dependencies {
testImplementation(libs.assertJCore)
testImplementation(libs.mockitoCore)
testImplementation(libs.springTest)
+ testImplementation(libs.jakartaWebsocketApi)
+ testImplementation(libs.jakartaWebsocketClientApi)
testCompileOnly(libs.hamcrest) // Needed for Spring mock MVC matchers
+ testCompileOnly(libs.findbugsJsr305)
}
tasks.named("asciidoctor").configure {
diff --git a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/CustomRequestBean.java b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/CustomRequestBean.java
index 014bbd6..fbef8ec 100644
--- a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/CustomRequestBean.java
+++ b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/CustomRequestBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.docs;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
@@ -25,6 +24,7 @@
import com.mattbertolini.spring.web.bind.annotation.RequestContext;
import com.mattbertolini.spring.web.bind.annotation.RequestParameter;
import com.mattbertolini.spring.web.bind.annotation.SessionParameter;
+import org.springframework.lang.Nullable;
import java.time.ZoneId;
import java.util.Locale;
@@ -37,6 +37,7 @@ public class CustomRequestBean {
// end::class[]
// Query parameters
+ @Nullable
// tag::queryParam[]
@RequestParameter("different_name")
private String queryParam;
@@ -44,6 +45,7 @@ public class CustomRequestBean {
// end::queryParam[]
// Form data
+ @Nullable
// tag::formParam[]
@FormParameter("form_data")
private String formData;
@@ -51,6 +53,7 @@ public class CustomRequestBean {
// end::formParam[]
// HTTP headers
+ @Nullable
// tag::headerParam[]
@HeaderParameter("X-Custom-Header")
private String headerValues;
@@ -58,6 +61,7 @@ public class CustomRequestBean {
// end::headerParam[]
// Spring MVC/WebFlux path variables
+ @Nullable
// tag::pathParam[]
@PathParameter("pathParam")
private Integer pathParam;
@@ -65,6 +69,7 @@ public class CustomRequestBean {
// end::pathParam[]
// HTTP cookie values
+ @Nullable
// tag::cookieParam[]
@CookieParameter("cookie_value")
private String cookieValue;
@@ -72,6 +77,7 @@ public class CustomRequestBean {
// end::cookieParam[]
// HTTP session attributes
+ @Nullable
// tag::sessionParam[]
@SessionParameter("sessionAttribute")
private String sessionAttribute;
@@ -79,16 +85,20 @@ public class CustomRequestBean {
// end::sessionParam[]
// Spring derived request scoped data like locale and time zone
+ @Nullable
@RequestContext
private Locale locale;
+ @Nullable
@RequestContext
private ZoneId timeZone;
// A nested Java bean with additional annotated properties
+ @Nullable
@BeanParameter
private NestedBean nestedBean;
+ @Nullable
// tag::queryParam[]
public String getQueryParam() {
return queryParam;
@@ -99,6 +109,7 @@ public void setQueryParam(String queryParam) {
}
// end::queryParam[]
+ @Nullable
// tag::formParam[]
public String getFormData() {
return formData;
@@ -109,6 +120,7 @@ public void setFormData(String formData) {
}
// end::formParam[]
+ @Nullable
// tag::headerParam[]
public String getHeaderValues() {
return headerValues;
@@ -119,6 +131,7 @@ public void setHeaderValues(String headerValues) {
}
// end::headerParam[]
+ @Nullable
// tag::pathParam[]
public Integer getPathParam() {
return pathParam;
@@ -129,6 +142,7 @@ public void setPathParam(Integer pathParam) {
}
// end::pathParam[]
+ @Nullable
// tag::cookieParam[]
public String getCookieValue() {
return cookieValue;
@@ -139,6 +153,7 @@ public void setCookieValue(String cookieValue) {
}
// end::cookieParam[]
+ @Nullable
// tag::sessionParam[]
public String getSessionAttribute() {
return sessionAttribute;
@@ -149,6 +164,7 @@ public void setSessionAttribute(String sessionAttribute) {
}
// end::sessionParam[]
+ @Nullable
public Locale getLocale() {
return locale;
}
@@ -157,6 +173,7 @@ public void setLocale(Locale locale) {
this.locale = locale;
}
+ @Nullable
public ZoneId getTimeZone() {
return timeZone;
}
@@ -165,6 +182,7 @@ public void setTimeZone(ZoneId timeZone) {
this.timeZone = timeZone;
}
+ @Nullable
public NestedBean getNestedBean() {
return nestedBean;
}
diff --git a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/ExampleController.java b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/ExampleController.java
index 16b679c..6e41cef 100644
--- a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/ExampleController.java
+++ b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/ExampleController.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.docs;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
diff --git a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/ExampleService.java b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/ExampleService.java
index 6fecc4f..f8968f2 100644
--- a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/ExampleService.java
+++ b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/ExampleService.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.docs;
public class ExampleService {
diff --git a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/NestedBean.java b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/NestedBean.java
index f56d300..0c27da8 100644
--- a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/NestedBean.java
+++ b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/NestedBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,15 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.docs;
import com.mattbertolini.spring.web.bind.annotation.RequestParameter;
+import org.springframework.lang.Nullable;
public class NestedBean {
+ @Nullable
@RequestParameter("nested_request_param")
private String nestedRequestParameter;
+ @Nullable
public String getNestedRequestParameter() {
return nestedRequestParameter;
}
diff --git a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/webflux/ExampleWebFluxContext.java b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/webflux/ExampleWebFluxContext.java
index edcb4af..1082e89 100644
--- a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/webflux/ExampleWebFluxContext.java
+++ b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/webflux/ExampleWebFluxContext.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.docs.webflux;
import com.mattbertolini.spring.web.bind.docs.ExampleController;
diff --git a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/webmvc/ExampleMvcContext.java b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/webmvc/ExampleMvcContext.java
index 79edb17..08926fe 100644
--- a/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/webmvc/ExampleMvcContext.java
+++ b/docs/src/main/java/com/mattbertolini/spring/web/bind/docs/webmvc/ExampleMvcContext.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.docs.webmvc;
import com.mattbertolini.spring.web.bind.docs.ExampleController;
diff --git a/docs/src/main/resources/com/mattbertolini/spring/web/bind/docs/webmvc/example-context.xml b/docs/src/main/resources/com/mattbertolini/spring/web/bind/docs/webmvc/example-context.xml
index dd4b8e7..f504c59 100644
--- a/docs/src/main/resources/com/mattbertolini/spring/web/bind/docs/webmvc/example-context.xml
+++ b/docs/src/main/resources/com/mattbertolini/spring/web/bind/docs/webmvc/example-context.xml
@@ -1,4 +1,21 @@
+
("compileJava").configure {
- options.release.set(17)
+ testCompileOnly(libs.findbugsJsr305)
}
tasks.named("jacocoTestReport").configure {
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/CookieParameterBean.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/CookieParameterBean.java
index 34c9f4f..7d9ac43 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/CookieParameterBean.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/CookieParameterBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,29 +13,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
import com.mattbertolini.spring.web.bind.annotation.CookieParameter;
-
-import javax.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotEmpty;
+import org.springframework.lang.Nullable;
public class CookieParameterBean {
+ @Nullable
@CookieParameter("annotated_field")
private String annotatedField;
+ @Nullable
private String annotatedSetter;
+ @Nullable
private String annotatedGetter;
+ @Nullable
@NotEmpty
@CookieParameter("validated")
private String validated;
+ @Nullable
@BeanParameter
private NestedBean nestedBean;
+ @Nullable
public String getAnnotatedField() {
return annotatedField;
}
@@ -44,6 +49,7 @@ public void setAnnotatedField(String annotatedField) {
this.annotatedField = annotatedField;
}
+ @Nullable
public String getAnnotatedSetter() {
return annotatedSetter;
}
@@ -53,6 +59,7 @@ public void setAnnotatedSetter(String annotatedSetter) {
this.annotatedSetter = annotatedSetter;
}
+ @Nullable
@CookieParameter("annotated_getter")
public String getAnnotatedGetter() {
return annotatedGetter;
@@ -62,6 +69,7 @@ public void setAnnotatedGetter(String annotatedGetter) {
this.annotatedGetter = annotatedGetter;
}
+ @Nullable
public String getValidated() {
return validated;
}
@@ -70,6 +78,7 @@ public void setValidated(String validated) {
this.validated = validated;
}
+ @Nullable
public NestedBean getNestedBean() {
return nestedBean;
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/CookieParameterController.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/CookieParameterController.java
index 572997f..886f78b 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/CookieParameterController.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/CookieParameterController.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,30 +13,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.test.web.bind.records.CookieParameterRecord;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
+import jakarta.validation.Valid;
import org.springframework.http.MediaType;
+import org.springframework.lang.Nullable;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
-import javax.validation.Valid;
+import java.util.Objects;
@RestController
public class CookieParameterController {
+ @Nullable
@GetMapping(value = "/annotatedField", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedField(@BeanParameter CookieParameterBean cookieParameterBean) {
return cookieParameterBean.getAnnotatedField();
}
+ @Nullable
@GetMapping(value = "/annotatedSetter", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedSetter(@BeanParameter CookieParameterBean cookieParameterBean) {
return cookieParameterBean.getAnnotatedSetter();
}
+ @Nullable
@GetMapping(value = "/annotatedGetter", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedGetter(@BeanParameter CookieParameterBean cookieParameterBean) {
return cookieParameterBean.getAnnotatedGetter();
@@ -47,6 +51,7 @@ public String bindingResult(@BeanParameter CookieParameterBean cookieParameterBe
return Integer.toString(bindingResult.getErrorCount());
}
+ @Nullable
@GetMapping(value = "/validated", produces = MediaType.TEXT_PLAIN_VALUE)
public String validated(@Valid @BeanParameter CookieParameterBean cookieParameterBean) {
return cookieParameterBean.getValidated();
@@ -60,9 +65,10 @@ public String validatedWithBindingResult(@Valid @BeanParameter CookieParameterBe
return "valid";
}
+ @Nullable
@GetMapping(value = "/nested", produces = MediaType.TEXT_PLAIN_VALUE)
public String nestedBean(@BeanParameter CookieParameterBean cookieParameterBean) {
- return cookieParameterBean.getNestedBean().getCookieValue();
+ return Objects.requireNonNull(cookieParameterBean.getNestedBean()).getCookieValue();
}
@GetMapping(value = "/record", produces = MediaType.TEXT_PLAIN_VALUE)
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/DirectFieldAccessBean.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/DirectFieldAccessBean.java
index 132f5a8..467ebfd 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/DirectFieldAccessBean.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/DirectFieldAccessBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.web.bind.annotation.CookieParameter;
@@ -23,55 +22,70 @@
import com.mattbertolini.spring.web.bind.annotation.RequestBody;
import com.mattbertolini.spring.web.bind.annotation.RequestParameter;
import com.mattbertolini.spring.web.bind.annotation.SessionParameter;
+import org.springframework.lang.Nullable;
@SuppressWarnings("unused")
public class DirectFieldAccessBean {
+ @Nullable
@CookieParameter("cookie_parameter")
private String cookieParameter;
+ @Nullable
@FormParameter("form_parameter")
private String formParameter;
-
+
+ @Nullable
@HeaderParameter("header_parameter")
private String headerParameter;
+ @Nullable
@PathParameter("path_parameter")
private String pathParameter;
-
+
+ @Nullable
@RequestParameter("request_parameter")
private String requestParameter;
+ @Nullable
@SessionParameter("session_parameter")
private String sessionParameter;
+ @Nullable
public String getCookieParameter() {
return cookieParameter;
}
+ @Nullable
public String getFormParameter() {
return formParameter;
}
+ @Nullable
public String getHeaderParameter() {
return headerParameter;
}
+ @Nullable
public String getPathParameter() {
return pathParameter;
}
+ @Nullable
public String getRequestParameter() {
return requestParameter;
}
+ @Nullable
public String getSessionParameter() {
return sessionParameter;
}
public static class RequestBodyBean {
+ @Nullable
@RequestBody
private JsonBody requestBody;
+ @Nullable
public JsonBody getRequestBody() {
return requestBody;
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/DirectFieldAccessController.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/DirectFieldAccessController.java
index ac1b24e..688c425 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/DirectFieldAccessController.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/DirectFieldAccessController.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,50 +13,59 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
import org.springframework.http.MediaType;
+import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
+import java.util.Objects;
+
@RestController
public class DirectFieldAccessController {
+ @Nullable
@GetMapping(value = "/cookieParameter", produces = MediaType.TEXT_PLAIN_VALUE)
public String cookieParameter(@BeanParameter DirectFieldAccessBean directFieldAccessBean) {
return directFieldAccessBean.getCookieParameter();
}
+ @Nullable
@PostMapping(value = "/formParameter", produces = MediaType.TEXT_PLAIN_VALUE)
public String formParameter(@BeanParameter DirectFieldAccessBean directFieldAccessBean) {
return directFieldAccessBean.getFormParameter();
}
+ @Nullable
@GetMapping(value = "/headerParameter", produces = MediaType.TEXT_PLAIN_VALUE)
public String headerParameter(@BeanParameter DirectFieldAccessBean directFieldAccessBean) {
return directFieldAccessBean.getHeaderParameter();
}
+ @Nullable
@SuppressWarnings("MVCPathVariableInspection")
@GetMapping(value = "/pathParameter/{path_parameter}", produces = MediaType.TEXT_PLAIN_VALUE)
public String pathParameter(@BeanParameter DirectFieldAccessBean directFieldAccessBean) {
return directFieldAccessBean.getPathParameter();
}
+ @Nullable
@GetMapping(value = "/requestParameter", produces = MediaType.TEXT_PLAIN_VALUE)
public String requestParameter(@BeanParameter DirectFieldAccessBean directFieldAccessBean) {
return directFieldAccessBean.getRequestParameter();
}
+ @Nullable
@GetMapping(value = "/sessionParameter", produces = MediaType.TEXT_PLAIN_VALUE)
public String sessionParameter(@BeanParameter DirectFieldAccessBean directFieldAccessBean) {
return directFieldAccessBean.getSessionParameter();
}
+ @Nullable
@PostMapping(value = "/requestBody", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.TEXT_PLAIN_VALUE)
public String requestBody(@BeanParameter DirectFieldAccessBean.RequestBodyBean directFieldAccessBean) {
- return directFieldAccessBean.getRequestBody().getProperty();
+ return Objects.requireNonNull(directFieldAccessBean.getRequestBody()).getProperty();
}
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/FormParameterBean.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/FormParameterBean.java
index 686f479..0e8ddc9 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/FormParameterBean.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/FormParameterBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2021 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,40 +13,48 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
import com.mattbertolini.spring.web.bind.annotation.FormParameter;
+import jakarta.servlet.http.Part;
+import jakarta.validation.constraints.NotEmpty;
import org.springframework.http.codec.multipart.FilePart;
+import org.springframework.lang.Nullable;
import org.springframework.util.MultiValueMap;
import org.springframework.web.multipart.MultipartFile;
-import javax.servlet.http.Part;
-import javax.validation.constraints.NotEmpty;
import java.util.Map;
public class FormParameterBean {
+ @Nullable
@FormParameter("annotated_field")
private String annotatedField;
+ @Nullable
private String annotatedSetter;
+ @Nullable
private String annotatedGetter;
+ @Nullable
@FormParameter
private Map simpleMap;
+ @Nullable
@FormParameter
private MultiValueMap multiValueMap;
+ @Nullable
@NotEmpty
@FormParameter("validated")
private String validated;
+ @Nullable
@BeanParameter
private NestedBean nestedBean;
+ @Nullable
public String getAnnotatedField() {
return annotatedField;
}
@@ -55,6 +63,7 @@ public void setAnnotatedField(String annotatedField) {
this.annotatedField = annotatedField;
}
+ @Nullable
public String getAnnotatedSetter() {
return annotatedSetter;
}
@@ -64,6 +73,7 @@ public void setAnnotatedSetter(String annotatedSetter) {
this.annotatedSetter = annotatedSetter;
}
+ @Nullable
@FormParameter("annotated_getter")
public String getAnnotatedGetter() {
return annotatedGetter;
@@ -73,6 +83,7 @@ public void setAnnotatedGetter(String annotatedGetter) {
this.annotatedGetter = annotatedGetter;
}
+ @Nullable
public Map getSimpleMap() {
return simpleMap;
}
@@ -81,6 +92,7 @@ public void setSimpleMap(Map simpleMap) {
this.simpleMap = simpleMap;
}
+ @Nullable
public MultiValueMap getMultiValueMap() {
return multiValueMap;
}
@@ -89,6 +101,7 @@ public void setMultiValueMap(MultiValueMap multiValueMap) {
this.multiValueMap = multiValueMap;
}
+ @Nullable
public String getValidated() {
return validated;
}
@@ -97,6 +110,7 @@ public void setValidated(String validated) {
this.validated = validated;
}
+ @Nullable
public NestedBean getNestedBean() {
return nestedBean;
}
@@ -109,24 +123,31 @@ public void setNestedBean(NestedBean nestedBean) {
* Test bean for multipart binding in a Servlet/WebMVC application
*/
static class ServletMultipartBean {
+ @Nullable
@FormParameter("file")
private MultipartFile multipartFile;
+ @Nullable
@FormParameter("part")
private Part part;
+ @Nullable
@FormParameter
private Map multipartFileMap;
+ @Nullable
@FormParameter
private MultiValueMap multiValueMultipartMap;
+ @Nullable
@FormParameter
private Map partMap;
+ @Nullable
@FormParameter
private MultiValueMap multiValuePartMap;
+ @Nullable
public MultipartFile getMultipartFile() {
return multipartFile;
}
@@ -135,6 +156,7 @@ public void setMultipartFile(MultipartFile multipartFile) {
this.multipartFile = multipartFile;
}
+ @Nullable
public Part getPart() {
return part;
}
@@ -143,6 +165,7 @@ public void setPart(Part part) {
this.part = part;
}
+ @Nullable
public Map getMultipartFileMap() {
return multipartFileMap;
}
@@ -151,6 +174,7 @@ public void setMultipartFileMap(Map multipartFileMap) {
this.multipartFileMap = multipartFileMap;
}
+ @Nullable
public MultiValueMap getMultiValueMultipartMap() {
return multiValueMultipartMap;
}
@@ -159,6 +183,7 @@ public void setMultiValueMultipartMap(MultiValueMap multi
this.multiValueMultipartMap = multiValueMultipartMap;
}
+ @Nullable
public Map getPartMap() {
return partMap;
}
@@ -167,6 +192,7 @@ public void setPartMap(Map partMap) {
this.partMap = partMap;
}
+ @Nullable
public MultiValueMap getMultiValuePartMap() {
return multiValuePartMap;
}
@@ -180,9 +206,11 @@ public void setMultiValuePartMap(MultiValueMap multiValuePartMap)
* Test bean for multipart binding in a WebFlux application
*/
static class WebfluxMultipartBean {
+ @Nullable
@FormParameter("file")
private FilePart filePart;
+ @Nullable
public FilePart getFilePart() {
return filePart;
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/FormParameterController.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/FormParameterController.java
index da5d072..09eb3b2 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/FormParameterController.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/FormParameterController.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,15 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.test.web.bind.records.FormParameterRecord;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
+import jakarta.servlet.http.Part;
+import jakarta.validation.Valid;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.http.MediaType;
import org.springframework.http.codec.multipart.FilePart;
+import org.springframework.lang.Nullable;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StreamUtils;
import org.springframework.validation.BindingResult;
@@ -30,42 +32,47 @@
import org.springframework.web.multipart.MultipartFile;
import reactor.core.publisher.Flux;
-import javax.servlet.http.Part;
-import javax.validation.Valid;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.stream.Collectors;
+@SuppressWarnings("NullAway")
@RestController
public class FormParameterController {
+ @Nullable
@PostMapping(value = "/annotatedField", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedField(@BeanParameter FormParameterBean formParameterBean) {
return formParameterBean.getAnnotatedField();
}
+ @Nullable
@PostMapping(value = "/annotatedSetter", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedSetter(@BeanParameter FormParameterBean formParameterBean) {
return formParameterBean.getAnnotatedSetter();
}
+ @Nullable
@PostMapping(value = "/annotatedGetter", produces = MediaType.TEXT_PLAIN_VALUE)
public String handleRequest(@BeanParameter FormParameterBean formParameterBean) {
return formParameterBean.getAnnotatedGetter();
}
+ @Nullable
@PostMapping(value = "/simpleMap", produces = MediaType.TEXT_PLAIN_VALUE)
public String simpleMap(@BeanParameter FormParameterBean formParameterBean) {
Map simpleMap = formParameterBean.getSimpleMap();
- return simpleMap.get("simple-map");
+ return Objects.requireNonNull(simpleMap).get("simple-map");
}
+ @Nullable
@PostMapping(value = "/multiValueMap", produces = MediaType.TEXT_PLAIN_VALUE)
public String multiValueMap(@BeanParameter FormParameterBean formParameterBean) {
MultiValueMap multiValueMap = formParameterBean.getMultiValueMap();
- return multiValueMap.getFirst("multi-value-map");
+ return Objects.requireNonNull(multiValueMap).getFirst("multi-value-map");
}
@SuppressWarnings("unused")
@@ -74,6 +81,7 @@ public String bindingResult(@BeanParameter FormParameterBean formParameterBean,
return Integer.toString(bindingResult.getErrorCount());
}
+ @Nullable
@PostMapping(value = "/validated", produces = MediaType.TEXT_PLAIN_VALUE)
public String validated(@Valid @BeanParameter FormParameterBean formParameterBean) {
return formParameterBean.getValidated();
@@ -94,7 +102,7 @@ public String multipartFile(@BeanParameter FormParameterBean.ServletMultipartBea
if (multipartFile == null || multipartFile.isEmpty()) {
throw new RuntimeException("Multipart file is null or empty");
}
- return new String(multipartFile.getBytes());
+ return new String(multipartFile.getBytes(), StandardCharsets.UTF_8);
}
@PostMapping(value = "/part", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@@ -111,7 +119,7 @@ public String multipartFileMap(@BeanParameter FormParameterBean.ServletMultipart
Map multipartFileMap = formParameterBean.getMultipartFileMap();
MultipartFile fileOne = multipartFileMap.get("fileOne");
MultipartFile fileTwo = multipartFileMap.get("fileTwo");
- return new String(fileOne.getBytes()) + ", " + new String(fileTwo.getBytes());
+ return new String(fileOne.getBytes(), StandardCharsets.UTF_8) + ", " + new String(fileTwo.getBytes(), StandardCharsets.UTF_8);
}
@PostMapping(value = "/multiValueMultipartFileMap", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@@ -120,7 +128,7 @@ public String multiValueMultipartFileMap(@BeanParameter FormParameterBean.Servle
List files = multiValueMultipartMap.get("file");
return files.stream().map(multipartFile -> {
try {
- return new String(multipartFile.getBytes());
+ return new String(multipartFile.getBytes(), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -161,9 +169,10 @@ public String webFluxFilePart(@BeanParameter FormParameterBean.WebfluxMultipartB
return new String(data.toByteArray(), StandardCharsets.UTF_8);
}
+ @Nullable
@PostMapping(value = "/nested", produces = MediaType.TEXT_PLAIN_VALUE)
public String nestedBeanParameter(@BeanParameter FormParameterBean formParameterBean) {
- return formParameterBean.getNestedBean().getFormData();
+ return Objects.requireNonNull(formParameterBean.getNestedBean()).getFormData();
}
@PostMapping(value = "/record", produces = MediaType.TEXT_PLAIN_VALUE)
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/HeaderParameterBean.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/HeaderParameterBean.java
index 30aa8e0..b039ab4 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/HeaderParameterBean.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/HeaderParameterBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,41 +13,50 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
import com.mattbertolini.spring.web.bind.annotation.HeaderParameter;
+import jakarta.validation.constraints.NotEmpty;
import org.springframework.http.HttpHeaders;
+import org.springframework.lang.Nullable;
import org.springframework.util.MultiValueMap;
-import javax.validation.constraints.NotEmpty;
import java.util.Map;
public class HeaderParameterBean {
+ @Nullable
@HeaderParameter("x-annotated-field")
private String annotatedField;
+ @Nullable
private String annotatedSetter;
+ @Nullable
private String annotatedGetter;
+ @Nullable
@HeaderParameter
private Map simpleMap;
+ @Nullable
@HeaderParameter
private MultiValueMap multiValueMap;
+ @Nullable
@HeaderParameter
private HttpHeaders httpHeaders;
+ @Nullable
@NotEmpty
@HeaderParameter("validated")
private String validated;
+ @Nullable
@BeanParameter
private NestedBean nestedBean;
+ @Nullable
public String getAnnotatedField() {
return annotatedField;
}
@@ -56,6 +65,7 @@ public void setAnnotatedField(String annotatedField) {
this.annotatedField = annotatedField;
}
+ @Nullable
public String getAnnotatedSetter() {
return annotatedSetter;
}
@@ -65,6 +75,7 @@ public void setAnnotatedSetter(String annotatedSetter) {
this.annotatedSetter = annotatedSetter;
}
+ @Nullable
@HeaderParameter("x-annotated-getter")
public String getAnnotatedGetter() {
return annotatedGetter;
@@ -74,6 +85,7 @@ public void setAnnotatedGetter(String annotatedGetter) {
this.annotatedGetter = annotatedGetter;
}
+ @Nullable
public Map getSimpleMap() {
return simpleMap;
}
@@ -82,6 +94,7 @@ public void setSimpleMap(Map simpleMap) {
this.simpleMap = simpleMap;
}
+ @Nullable
public MultiValueMap getMultiValueMap() {
return multiValueMap;
}
@@ -90,6 +103,7 @@ public void setMultiValueMap(MultiValueMap multiValueMap) {
this.multiValueMap = multiValueMap;
}
+ @Nullable
public HttpHeaders getHttpHeaders() {
return httpHeaders;
}
@@ -98,6 +112,7 @@ public void setHttpHeaders(HttpHeaders httpHeaders) {
this.httpHeaders = httpHeaders;
}
+ @Nullable
public String getValidated() {
return validated;
}
@@ -106,6 +121,7 @@ public void setValidated(String validated) {
this.validated = validated;
}
+ @Nullable
public NestedBean getNestedBean() {
return nestedBean;
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/HeaderParameterController.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/HeaderParameterController.java
index 4ce66a5..1761736 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/HeaderParameterController.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/HeaderParameterController.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,54 +13,59 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.test.web.bind.records.HeaderParameterRecord;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
+import jakarta.validation.Valid;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
+import org.springframework.lang.Nullable;
import org.springframework.util.MultiValueMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
-import javax.validation.Valid;
import java.util.Map;
+import java.util.Objects;
@RestController
public class HeaderParameterController {
+ @Nullable
@GetMapping(value = "/annotatedField", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedField(@BeanParameter HeaderParameterBean headerParameterBean) {
return headerParameterBean.getAnnotatedField();
}
+ @Nullable
@GetMapping(value = "/annotatedSetter", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedSetter(@BeanParameter HeaderParameterBean headerParameterBean) {
return headerParameterBean.getAnnotatedSetter();
}
+ @Nullable
@GetMapping(value = "/annotatedGetter", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedGetter(@BeanParameter HeaderParameterBean headerParameterBean) {
return headerParameterBean.getAnnotatedGetter();
}
+ @Nullable
@GetMapping(value = "/simpleMap", produces = MediaType.TEXT_PLAIN_VALUE)
public String simpleMap(@BeanParameter HeaderParameterBean headerParameterBean) {
Map simpleMap = headerParameterBean.getSimpleMap();
- return simpleMap.get("x-simple-map");
+ return Objects.requireNonNull(simpleMap).get("x-simple-map");
}
@GetMapping(value = "/multiValueMap", produces = MediaType.TEXT_PLAIN_VALUE)
public String multiValueMap(@BeanParameter HeaderParameterBean headerParameterBean) {
MultiValueMap multiValueMap = headerParameterBean.getMultiValueMap();
- return multiValueMap.getFirst("x-multivalue-map");
+ return Objects.requireNonNull(multiValueMap).getFirst("x-multivalue-map");
}
@GetMapping(value = "/httpHeaders", produces = MediaType.TEXT_PLAIN_VALUE)
public String httpHeaders(@BeanParameter HeaderParameterBean headerParameterBean) {
HttpHeaders httpHeaders = headerParameterBean.getHttpHeaders();
- return httpHeaders.getFirst("x-http-headers");
+ return Objects.requireNonNull(httpHeaders).getFirst("x-http-headers");
}
@GetMapping(value = "/bindingResult", produces = MediaType.TEXT_PLAIN_VALUE)
@@ -68,6 +73,7 @@ public String bindingResult(@BeanParameter HeaderParameterBean headerParameterBe
return Integer.toString(bindingResult.getErrorCount());
}
+ @Nullable
@GetMapping(value = "/validated", produces = MediaType.TEXT_PLAIN_VALUE)
public String validated(@Valid @BeanParameter HeaderParameterBean headerParameterBean) {
return headerParameterBean.getValidated();
@@ -81,9 +87,10 @@ public String validatedWithBindingResult(@Valid @BeanParameter HeaderParameterBe
return "valid";
}
+ @Nullable
@GetMapping(value = "/nested", produces = MediaType.TEXT_PLAIN_VALUE)
public String nestedBean(@BeanParameter HeaderParameterBean headerParameterBean) {
- return headerParameterBean.getNestedBean().getHeaderValue();
+ return Objects.requireNonNull(headerParameterBean.getNestedBean()).getHeaderValue();
}
@GetMapping(value = "/record", produces = MediaType.TEXT_PLAIN_VALUE)
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/JsonBody.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/JsonBody.java
index 667ad64..78f57ff 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/JsonBody.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/JsonBody.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2021 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,19 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import org.springframework.lang.Nullable;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class JsonBody {
+ @Nullable
@JsonProperty("json_property")
private String property;
+ @Nullable
public String getProperty() {
return property;
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/NestedBean.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/NestedBean.java
index 3132b99..c7dda8e 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/NestedBean.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/NestedBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2021 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.web.bind.annotation.CookieParameter;
@@ -23,27 +22,35 @@
import com.mattbertolini.spring.web.bind.annotation.RequestBody;
import com.mattbertolini.spring.web.bind.annotation.RequestParameter;
import com.mattbertolini.spring.web.bind.annotation.SessionParameter;
+import org.springframework.lang.Nullable;
@SuppressWarnings("unused")
public class NestedBean {
+ @Nullable
@RequestParameter("nested_query_param")
private String queryParam;
+ @Nullable
@FormParameter("nested_form_param")
private String formData;
+ @Nullable
@CookieParameter("nested_cookie_param")
private String cookieValue;
+ @Nullable
@HeaderParameter("nested_header_param")
private String headerValue;
+ @Nullable
@PathParameter("nested_path_param")
private String pathVariable;
+ @Nullable
@SessionParameter("nested_session_param")
private String sessionAttribute;
+ @Nullable
public String getQueryParam() {
return queryParam;
}
@@ -52,6 +59,7 @@ public void setQueryParam(String queryParam) {
this.queryParam = queryParam;
}
+ @Nullable
public String getFormData() {
return formData;
}
@@ -60,6 +68,7 @@ public void setFormData(String formData) {
this.formData = formData;
}
+ @Nullable
public String getCookieValue() {
return cookieValue;
}
@@ -68,6 +77,7 @@ public void setCookieValue(String cookieValue) {
this.cookieValue = cookieValue;
}
+ @Nullable
public String getHeaderValue() {
return headerValue;
}
@@ -76,6 +86,7 @@ public void setHeaderValue(String headerValue) {
this.headerValue = headerValue;
}
+ @Nullable
public String getPathVariable() {
return pathVariable;
}
@@ -84,6 +95,7 @@ public void setPathVariable(String pathVariable) {
this.pathVariable = pathVariable;
}
+ @Nullable
public String getSessionAttribute() {
return sessionAttribute;
}
@@ -93,9 +105,11 @@ public void setSessionAttribute(String sessionAttribute) {
}
public static class RequestBodyBean {
+ @Nullable
@RequestBody
private JsonBody requestBody;
+ @Nullable
public JsonBody getRequestBody() {
return requestBody;
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/PathParameterBean.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/PathParameterBean.java
index 8c33df5..1d1b6f4 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/PathParameterBean.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/PathParameterBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,33 +13,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
import com.mattbertolini.spring.web.bind.annotation.PathParameter;
+import jakarta.validation.constraints.NotEmpty;
+import org.springframework.lang.Nullable;
-import javax.validation.constraints.NotEmpty;
import java.util.Map;
public class PathParameterBean {
+ @Nullable
@PathParameter("annotated_field")
private String annotatedField;
+ @Nullable
private String annotatedSetter;
+ @Nullable
private String annotatedGetter;
+ @Nullable
@PathParameter
private Map simpleMap;
+ @Nullable
@NotEmpty
@PathParameter("validated")
private String validated;
+ @Nullable
@BeanParameter
private NestedBean nestedBean;
+ @Nullable
public String getAnnotatedField() {
return annotatedField;
}
@@ -48,6 +55,7 @@ public void setAnnotatedField(String annotatedField) {
this.annotatedField = annotatedField;
}
+ @Nullable
public String getAnnotatedSetter() {
return annotatedSetter;
}
@@ -57,6 +65,7 @@ public void setAnnotatedSetter(String annotatedSetter) {
this.annotatedSetter = annotatedSetter;
}
+ @Nullable
@PathParameter("annotated_getter")
public String getAnnotatedGetter() {
return annotatedGetter;
@@ -66,6 +75,7 @@ public void setAnnotatedGetter(String annotatedGetter) {
this.annotatedGetter = annotatedGetter;
}
+ @Nullable
public Map getSimpleMap() {
return simpleMap;
}
@@ -74,6 +84,7 @@ public void setSimpleMap(Map simpleMap) {
this.simpleMap = simpleMap;
}
+ @Nullable
public String getValidated() {
return validated;
}
@@ -82,6 +93,7 @@ public void setValidated(String validated) {
this.validated = validated;
}
+ @Nullable
public NestedBean getNestedBean() {
return nestedBean;
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/PathParameterController.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/PathParameterController.java
index 473bde8..2c09869 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/PathParameterController.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/PathParameterController.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,41 +13,46 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.test.web.bind.records.PathParameterRecord;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
+import jakarta.validation.Valid;
import org.springframework.http.MediaType;
+import org.springframework.lang.Nullable;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
-import javax.validation.Valid;
import java.util.Map;
+import java.util.Objects;
@SuppressWarnings("MVCPathVariableInspection")
@RestController
public class PathParameterController {
+ @Nullable
@GetMapping(value = "/annotatedField/{annotated_field}", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedField(@BeanParameter PathParameterBean pathParameterBean) {
return pathParameterBean.getAnnotatedField();
}
+ @Nullable
@GetMapping(value = "/annotatedSetter/{annotated_setter}", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedSetter(@BeanParameter PathParameterBean pathParameterBean) {
return pathParameterBean.getAnnotatedSetter();
}
+ @Nullable
@GetMapping(value = "/annotatedGetter/{annotated_getter}", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedGetter(@BeanParameter PathParameterBean pathParameterBean) {
return pathParameterBean.getAnnotatedGetter();
}
+ @Nullable
@GetMapping(value = "/simpleMap/{simple_map}")
public String simpleMap(@BeanParameter PathParameterBean pathParameterBean) {
Map simpleMap = pathParameterBean.getSimpleMap();
- return simpleMap.get("simple_map");
+ return Objects.requireNonNull(simpleMap).get("simple_map");
}
@GetMapping(value = "/bindingResult/{validated}", produces = MediaType.TEXT_PLAIN_VALUE)
@@ -55,6 +60,7 @@ public String bindingResult(@BeanParameter PathParameterBean pathParameterBean,
return Integer.toString(bindingResult.getErrorCount());
}
+ @Nullable
@GetMapping(value = {"/validated", "/validated/{validated}"}, produces = MediaType.TEXT_PLAIN_VALUE)
public String validated(@Valid @BeanParameter PathParameterBean pathParameterBean) {
return pathParameterBean.getValidated();
@@ -68,9 +74,10 @@ public String validatedWithBindingResult(@Valid @BeanParameter PathParameterBean
return "valid";
}
+ @Nullable
@GetMapping(value = "/nested/{nested_path_param}", produces = MediaType.TEXT_PLAIN_VALUE)
public String nestedBean(@BeanParameter PathParameterBean pathParameterBean) {
- return pathParameterBean.getNestedBean().getPathVariable();
+ return Objects.requireNonNull(pathParameterBean.getNestedBean()).getPathVariable();
}
@GetMapping(value = "/record/{annotated_field}", produces = MediaType.TEXT_PLAIN_VALUE)
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestBodyBean.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestBodyBean.java
index 9d59242..4e18329 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestBodyBean.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestBodyBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2021 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,24 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
import com.mattbertolini.spring.web.bind.annotation.RequestBody;
+import jakarta.validation.constraints.NotNull;
import org.springframework.http.codec.multipart.Part;
+import org.springframework.lang.Nullable;
import org.springframework.util.MultiValueMap;
import reactor.core.publisher.Flux;
-import javax.validation.constraints.NotNull;
-
public class RequestBodyBean {
@SuppressWarnings("unused")
public static class AnnotatedField {
+ @Nullable
@RequestBody
private JsonBody jsonBody;
+ @Nullable
public JsonBody getJsonBody() {
return jsonBody;
}
@@ -42,8 +43,10 @@ public void setJsonBody(JsonBody jsonBody) {
@SuppressWarnings("unused")
public static class AnnotatedSetter {
+ @Nullable
private JsonBody jsonBody;
+ @Nullable
public JsonBody getJsonBody() {
return jsonBody;
}
@@ -56,8 +59,10 @@ public void setJsonBody(JsonBody jsonBody) {
@SuppressWarnings("unused")
public static class AnnotatedGetter {
+ @Nullable
private JsonBody jsonBody;
+ @Nullable
@RequestBody
public JsonBody getJsonBody() {
return jsonBody;
@@ -70,9 +75,11 @@ public void setJsonBody(JsonBody jsonBody) {
@SuppressWarnings("unused")
public static class BindingResult {
+ @Nullable
@RequestBody
private JsonBody jsonBody;
+ @Nullable
public JsonBody getJsonBody() {
return jsonBody;
}
@@ -84,10 +91,13 @@ public void setJsonBody(JsonBody jsonBody) {
@SuppressWarnings("unused")
public static class Validation {
+ @SuppressWarnings("MultipleNullnessAnnotations")
+ @Nullable
@NotNull
@RequestBody
private JsonBody jsonBody;
-
+
+ @Nullable
public JsonBody getJsonBody() {
return jsonBody;
}
@@ -99,9 +109,11 @@ public void setJsonBody(JsonBody jsonBody) {
@SuppressWarnings("unused")
public static class Nested {
+ @Nullable
@BeanParameter
private NestedBean.RequestBodyBean nestedBean;
+ @Nullable
public NestedBean.RequestBodyBean getNestedBean() {
return nestedBean;
}
@@ -113,9 +125,11 @@ public void setNestedBean(NestedBean.RequestBodyBean nestedBean) {
@SuppressWarnings("unused")
public static class WebFluxMultipartMultiValueMap {
+ @Nullable
@RequestBody
private MultiValueMap parts;
+ @Nullable
public MultiValueMap getParts() {
return parts;
}
@@ -127,9 +141,11 @@ public void setParts(MultiValueMap parts) {
@SuppressWarnings("unused")
public static class WebFluxMultipartFlux {
+ @Nullable
@RequestBody
private Flux parts;
+ @Nullable
public Flux getParts() {
return parts;
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestBodyController.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestBodyController.java
index 5b53c11..5305263 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestBodyController.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestBodyController.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.test.web.bind.records.RequestBodyRecord;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
+import jakarta.validation.Valid;
import org.springframework.http.MediaType;
import org.springframework.http.codec.multipart.Part;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap;
import org.springframework.validation.BindingResult;
@@ -27,27 +28,31 @@
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
-import javax.validation.Valid;
+import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
+@SuppressWarnings("NullAway")
@RestController
public class RequestBodyController {
+ @Nullable
@PostMapping(value = "/annotatedField", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public String annotatedField(@BeanParameter RequestBodyBean.AnnotatedField requestBodyBean) {
JsonBody jsonBody = requestBodyBean.getJsonBody();
- return jsonBody.getProperty();
+ return Objects.requireNonNull(jsonBody).getProperty();
}
+ @Nullable
@PostMapping(value = "/annotatedSetter", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public String annotatedSetter(@BeanParameter RequestBodyBean.AnnotatedSetter requestBodyBean) {
JsonBody jsonBody = requestBodyBean.getJsonBody();
- return jsonBody.getProperty();
+ return Objects.requireNonNull(jsonBody).getProperty();
}
+ @Nullable
@PostMapping(value = "/annotatedGetter", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public String annotatedGetter(@BeanParameter RequestBodyBean.AnnotatedGetter requestBodyBean) {
JsonBody jsonBody = requestBodyBean.getJsonBody();
- return jsonBody.getProperty();
+ return Objects.requireNonNull(jsonBody).getProperty();
}
@SuppressWarnings("unused")
@@ -56,9 +61,10 @@ public String bindingResult(@BeanParameter RequestBodyBean.BindingResult request
return Integer.toString(bindingResult.getErrorCount());
}
+ @Nullable
@PostMapping(value = "/validated", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public String validated(@Valid @BeanParameter RequestBodyBean.Validation requestBodyBean) {
- return requestBodyBean.getJsonBody().getProperty();
+ return Objects.requireNonNull(requestBodyBean.getJsonBody()).getProperty();
}
@SuppressWarnings("unused")
@@ -70,9 +76,10 @@ public String validatedWithBindingResult(@Valid @BeanParameter RequestBodyBean.V
return "valid";
}
+ @Nullable
@PostMapping(value = "/nested", produces = MediaType.TEXT_PLAIN_VALUE)
public String nestedBeanParameter(@BeanParameter RequestBodyBean.Nested requestBodyBean) {
- return requestBodyBean.getNestedBean().getRequestBody().getProperty();
+ return Objects.requireNonNull(Objects.requireNonNull(requestBodyBean.getNestedBean()).getRequestBody()).getProperty();
}
@PostMapping(value = "/multipartMultiValueMap", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@@ -93,6 +100,7 @@ public String multipartFlux(@BeanParameter RequestBodyBean.WebFluxMultipartFlux
return "multipartFlux " + count.get();
}
+ @Nullable
@PostMapping(value = "/record", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public String javaRecord(@BeanParameter RequestBodyRecord requestBodyRecord) {
JsonBody jsonBody = requestBodyRecord.jsonBody();
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestContextBean.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestContextBean.java
index d23a638..22a2dce 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestContextBean.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestContextBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,54 +13,67 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.web.bind.annotation.RequestContext;
+import jakarta.servlet.http.HttpSession;
import org.springframework.http.HttpMethod;
+import org.springframework.lang.Nullable;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebSession;
-import javax.servlet.http.HttpSession;
import java.time.ZoneId;
import java.util.Locale;
import java.util.TimeZone;
@SuppressWarnings("unused")
public class RequestContextBean {
+ @Nullable
@RequestContext
private NativeWebRequest webRequestField;
+ @Nullable
private NativeWebRequest webRequestSetter;
+ @Nullable
private NativeWebRequest webRequestGetter;
+ @Nullable
@RequestContext
private ServerWebExchange exchangeField;
+ @Nullable
private ServerWebExchange exchangeSetter;
+ @Nullable
private ServerWebExchange exchangeGetter;
+ @Nullable
@RequestContext
private Locale locale;
+ @Nullable
@RequestContext
private TimeZone timeZone;
+ @Nullable
@RequestContext
private ZoneId zoneId;
+ @Nullable
@RequestContext
private HttpMethod method;
+ @Nullable
@RequestContext
private HttpSession httpSession;
+ @Nullable
@RequestContext
private WebSession webSession;
+ @Nullable
public NativeWebRequest getWebRequestField() {
return webRequestField;
}
@@ -69,6 +82,7 @@ public void setWebRequestField(NativeWebRequest webRequestField) {
this.webRequestField = webRequestField;
}
+ @Nullable
public NativeWebRequest getWebRequestSetter() {
return webRequestSetter;
}
@@ -78,6 +92,7 @@ public void setWebRequestSetter(NativeWebRequest webRequestSetter) {
this.webRequestSetter = webRequestSetter;
}
+ @Nullable
@RequestContext
public NativeWebRequest getWebRequestGetter() {
return webRequestGetter;
@@ -87,6 +102,7 @@ public void setWebRequestGetter(NativeWebRequest webRequestGetter) {
this.webRequestGetter = webRequestGetter;
}
+ @Nullable
public ServerWebExchange getExchangeField() {
return exchangeField;
}
@@ -95,6 +111,7 @@ public void setExchangeField(ServerWebExchange exchangeField) {
this.exchangeField = exchangeField;
}
+ @Nullable
public ServerWebExchange getExchangeSetter() {
return exchangeSetter;
}
@@ -104,6 +121,7 @@ public void setExchangeSetter(ServerWebExchange exchangeSetter) {
this.exchangeSetter = exchangeSetter;
}
+ @Nullable
@RequestContext
public ServerWebExchange getExchangeGetter() {
return exchangeGetter;
@@ -113,6 +131,7 @@ public void setExchangeGetter(ServerWebExchange exchangeGetter) {
this.exchangeGetter = exchangeGetter;
}
+ @Nullable
public Locale getLocale() {
return locale;
}
@@ -121,6 +140,7 @@ public void setLocale(Locale locale) {
this.locale = locale;
}
+ @Nullable
public TimeZone getTimeZone() {
return timeZone;
}
@@ -129,6 +149,7 @@ public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
}
+ @Nullable
public ZoneId getZoneId() {
return zoneId;
}
@@ -137,6 +158,7 @@ public void setZoneId(ZoneId zoneId) {
this.zoneId = zoneId;
}
+ @Nullable
public HttpMethod getMethod() {
return method;
}
@@ -145,6 +167,7 @@ public void setMethod(HttpMethod method) {
this.method = method;
}
+ @Nullable
public HttpSession getHttpSession() {
return httpSession;
}
@@ -153,6 +176,7 @@ public void setHttpSession(HttpSession httpSession) {
this.httpSession = httpSession;
}
+ @Nullable
public WebSession getWebSession() {
return webSession;
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestContextController.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestContextController.java
index 821209b..5503da4 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestContextController.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestContextController.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,15 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.test.web.bind.records.RequestContextRecord;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
import org.springframework.http.MediaType;
+import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
+import java.util.Objects;
+
import static org.assertj.core.api.Assertions.assertThat;
@RestController
@@ -65,14 +67,16 @@ public String exchangeGetter(@BeanParameter RequestContextBean requestContextBea
}
// Locale
+ @Nullable
@GetMapping(value = "/locale", produces = MediaType.TEXT_PLAIN_VALUE)
public String locale(@BeanParameter RequestContextBean requestContextBean) {
- return requestContextBean.getLocale().toString();
+ return Objects.requireNonNull(requestContextBean.getLocale()).toString();
}
+ @Nullable
@GetMapping(value = "/timeZone", produces = MediaType.TEXT_PLAIN_VALUE)
public String timeZone(@BeanParameter RequestContextBean requestContextBean) {
- return requestContextBean.getTimeZone().toString();
+ return Objects.requireNonNull(requestContextBean.getTimeZone()).toString();
}
@GetMapping(value = "/timeZoneRecord", produces = MediaType.TEXT_PLAIN_VALUE)
@@ -80,23 +84,27 @@ public String javaRecordTimeZone(@BeanParameter RequestContextRecord requestCont
return requestContextRecord.timeZone().toString();
}
+ @Nullable
@GetMapping(value = "/zoneId", produces = MediaType.TEXT_PLAIN_VALUE)
public String zoneId(@BeanParameter RequestContextBean requestContextBean) {
- return requestContextBean.getZoneId().toString();
+ return Objects.requireNonNull(requestContextBean.getZoneId()).toString();
}
+ @Nullable
@GetMapping(value = "/method", produces = MediaType.TEXT_PLAIN_VALUE)
public String method(@BeanParameter RequestContextBean requestContextBean) {
- return requestContextBean.getMethod().toString();
+ return Objects.requireNonNull(requestContextBean.getMethod()).toString();
}
+ @Nullable
@GetMapping(value = "/session", produces = MediaType.TEXT_PLAIN_VALUE)
public String httpSession(@BeanParameter RequestContextBean requestContextBean) {
- return (String) requestContextBean.getHttpSession().getAttribute("name");
+ return (String) Objects.requireNonNull(requestContextBean.getHttpSession()).getAttribute("name");
}
+ @Nullable
@GetMapping(value = "/webSession", produces = MediaType.TEXT_PLAIN_VALUE)
public String webSession(@BeanParameter RequestContextBean requestContextBean) {
- return requestContextBean.getWebSession().getAttribute("name");
+ return Objects.requireNonNull(requestContextBean.getWebSession()).getAttribute("name");
}
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestParameterBean.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestParameterBean.java
index 73f239e..2a38bd6 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestParameterBean.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestParameterBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2021 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,39 +13,47 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
import com.mattbertolini.spring.web.bind.annotation.RequestParameter;
+import jakarta.servlet.http.Part;
+import jakarta.validation.constraints.NotEmpty;
+import org.springframework.lang.Nullable;
import org.springframework.util.MultiValueMap;
import org.springframework.web.multipart.MultipartFile;
-import javax.servlet.http.Part;
-import javax.validation.constraints.NotEmpty;
import java.util.Map;
public class RequestParameterBean {
+ @Nullable
@RequestParameter("annotated_field")
private String annotatedField;
+ @Nullable
private String annotatedSetter;
+ @Nullable
private String annotatedGetter;
+ @Nullable
@RequestParameter
private Map simpleMap;
+ @Nullable
@RequestParameter
private MultiValueMap multiValueMap;
+ @Nullable
@NotEmpty
@RequestParameter("validated")
private String validated;
+ @Nullable
@BeanParameter
private NestedBean nestedBean;
+ @Nullable
public String getAnnotatedField() {
return annotatedField;
}
@@ -54,6 +62,7 @@ public void setAnnotatedField(String annotatedField) {
this.annotatedField = annotatedField;
}
+ @Nullable
public String getAnnotatedSetter() {
return annotatedSetter;
}
@@ -63,6 +72,7 @@ public void setAnnotatedSetter(String annotatedSetter) {
this.annotatedSetter = annotatedSetter;
}
+ @Nullable
@RequestParameter("annotated_getter")
public String getAnnotatedGetter() {
return annotatedGetter;
@@ -72,6 +82,7 @@ public void setAnnotatedGetter(String annotatedGetter) {
this.annotatedGetter = annotatedGetter;
}
+ @Nullable
public Map getSimpleMap() {
return simpleMap;
}
@@ -80,6 +91,7 @@ public void setSimpleMap(Map simpleMap) {
this.simpleMap = simpleMap;
}
+ @Nullable
public MultiValueMap getMultiValueMap() {
return multiValueMap;
}
@@ -88,6 +100,7 @@ public void setMultiValueMap(MultiValueMap multiValueMap) {
this.multiValueMap = multiValueMap;
}
+ @Nullable
public String getValidated() {
return validated;
}
@@ -96,6 +109,7 @@ public void setValidated(String validated) {
this.validated = validated;
}
+ @Nullable
public NestedBean getNestedBean() {
return nestedBean;
}
@@ -107,25 +121,32 @@ public void setNestedBean(NestedBean nestedBean) {
/**
* Test bean for multipart binding in a Servlet/WebMVC application
*/
- static class ServletMultipartBean {
+ public static class ServletMultipartBean {
+ @Nullable
@RequestParameter("file")
private MultipartFile multipartFile;
+ @Nullable
@RequestParameter("part")
private Part part;
+ @Nullable
@RequestParameter
private Map multipartFileMap;
+ @Nullable
@RequestParameter
private MultiValueMap multiValueMultipartMap;
+ @Nullable
@RequestParameter
private Map partMap;
+ @Nullable
@RequestParameter
private MultiValueMap multiValuePartMap;
+ @Nullable
public MultipartFile getMultipartFile() {
return multipartFile;
}
@@ -134,6 +155,7 @@ public void setMultipartFile(MultipartFile multipartFile) {
this.multipartFile = multipartFile;
}
+ @Nullable
public Part getPart() {
return part;
}
@@ -142,6 +164,7 @@ public void setPart(Part part) {
this.part = part;
}
+ @Nullable
public Map getMultipartFileMap() {
return multipartFileMap;
}
@@ -150,6 +173,7 @@ public void setMultipartFileMap(Map multipartFileMap) {
this.multipartFileMap = multipartFileMap;
}
+ @Nullable
public MultiValueMap getMultiValueMultipartMap() {
return multiValueMultipartMap;
}
@@ -158,6 +182,7 @@ public void setMultiValueMultipartMap(MultiValueMap multi
this.multiValueMultipartMap = multiValueMultipartMap;
}
+ @Nullable
public Map getPartMap() {
return partMap;
}
@@ -166,6 +191,7 @@ public void setPartMap(Map partMap) {
this.partMap = partMap;
}
+ @Nullable
public MultiValueMap getMultiValuePartMap() {
return multiValuePartMap;
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestParameterController.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestParameterController.java
index 7edb153..a7ef194 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestParameterController.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/RequestParameterController.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.test.web.bind.records.RequestParameterRecord;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
+import jakarta.servlet.http.Part;
+import jakarta.validation.Valid;
import org.springframework.http.MediaType;
+import org.springframework.lang.Nullable;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StreamUtils;
import org.springframework.validation.BindingResult;
@@ -27,41 +29,46 @@
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
-import javax.servlet.http.Part;
-import javax.validation.Valid;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.stream.Collectors;
+@SuppressWarnings("NullAway")
@RestController
public class RequestParameterController {
+ @Nullable
@GetMapping(value = "/annotatedField", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedField(@BeanParameter RequestParameterBean requestParameterBean) {
return requestParameterBean.getAnnotatedField();
}
+ @Nullable
@GetMapping(value = "/annotatedSetter", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedSetter(@BeanParameter RequestParameterBean requestParameterBean) {
return requestParameterBean.getAnnotatedSetter();
}
+ @Nullable
@GetMapping(value = "/annotatedGetter", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedGetter(@BeanParameter RequestParameterBean requestParameterBean) {
return requestParameterBean.getAnnotatedGetter();
}
+ @Nullable
@GetMapping(value = "/simpleMap", produces = MediaType.TEXT_PLAIN_VALUE)
public String simpleMap(@BeanParameter RequestParameterBean requestParameterBean) {
Map simpleMap = requestParameterBean.getSimpleMap();
- return simpleMap.get("simpleMap");
+ return Objects.requireNonNull(simpleMap).get("simpleMap");
}
+ @Nullable
@GetMapping(value = "/multiValueMap", produces = MediaType.TEXT_PLAIN_VALUE)
public String multiValueMap(@BeanParameter RequestParameterBean requestParameterBean) {
MultiValueMap multiValueMap = requestParameterBean.getMultiValueMap();
- return multiValueMap.getFirst("multiValueMap");
+ return Objects.requireNonNull(multiValueMap).getFirst("multiValueMap");
}
@GetMapping(value = "/bindingResult", produces = MediaType.TEXT_PLAIN_VALUE)
@@ -69,6 +76,7 @@ public String bindingResult(@BeanParameter RequestParameterBean requestParameter
return Integer.toString(bindingResult.getErrorCount());
}
+ @Nullable
@GetMapping(value = "/validated", produces = MediaType.TEXT_PLAIN_VALUE)
public String validated(@Valid @BeanParameter RequestParameterBean requestParameterBean) {
return requestParameterBean.getValidated();
@@ -88,7 +96,7 @@ public String multipartFile(@BeanParameter RequestParameterBean.ServletMultipart
if (multipartFile == null || multipartFile.isEmpty()) {
throw new RuntimeException("Multipart file is null or empty");
}
- return new String(multipartFile.getBytes());
+ return new String(multipartFile.getBytes(), StandardCharsets.UTF_8);
}
@PostMapping(value = "/part", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@@ -103,9 +111,9 @@ public String part(@BeanParameter RequestParameterBean.ServletMultipartBean requ
@PostMapping(value = "/multipartFileMap", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public String multipartFileMap(@BeanParameter RequestParameterBean.ServletMultipartBean requestParameterBean) throws Exception {
Map multipartFileMap = requestParameterBean.getMultipartFileMap();
- MultipartFile fileOne = multipartFileMap.get("fileOne");
+ MultipartFile fileOne = Objects.requireNonNull(multipartFileMap).get("fileOne");
MultipartFile fileTwo = multipartFileMap.get("fileTwo");
- return new String(fileOne.getBytes()) + ", " + new String(fileTwo.getBytes());
+ return new String(fileOne.getBytes(), StandardCharsets.UTF_8) + ", " + new String(fileTwo.getBytes(), StandardCharsets.UTF_8);
}
@PostMapping(value = "/multiValueMultipartFileMap", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@@ -114,7 +122,7 @@ public String multiValueMultipartFileMap(@BeanParameter RequestParameterBean.Ser
List files = multiValueMultipartMap.get("file");
return files.stream().map(multipartFile -> {
try {
- return new String(multipartFile.getBytes());
+ return new String(multipartFile.getBytes(), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -133,7 +141,7 @@ public String partMap(@BeanParameter RequestParameterBean.ServletMultipartBean r
@PostMapping(value = "/multiValuePartMap", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public String multiValuePartMap(@BeanParameter RequestParameterBean.ServletMultipartBean requestParameterBean) {
MultiValueMap multiValuePartMap = requestParameterBean.getMultiValuePartMap();
- List files = multiValuePartMap.get("file");
+ List files = Objects.requireNonNull(multiValuePartMap).get("file");
return files.stream().map(part -> {
try {
return StreamUtils.copyToString(part.getInputStream(), StandardCharsets.UTF_8);
@@ -143,9 +151,10 @@ public String multiValuePartMap(@BeanParameter RequestParameterBean.ServletMulti
}).collect(Collectors.joining(", "));
}
+ @Nullable
@GetMapping(value = "/nested", produces = MediaType.TEXT_PLAIN_VALUE)
public String nestedBeanParameter(@BeanParameter RequestParameterBean requestParameterBean) {
- return requestParameterBean.getNestedBean().getQueryParam();
+ return Objects.requireNonNull(requestParameterBean.getNestedBean()).getQueryParam();
}
@GetMapping(value = "/record", produces = MediaType.TEXT_PLAIN_VALUE)
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/SessionParameterBean.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/SessionParameterBean.java
index 01b7f1b..429ff26 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/SessionParameterBean.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/SessionParameterBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,30 +13,35 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
import com.mattbertolini.spring.web.bind.annotation.SessionParameter;
-
-import javax.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotEmpty;
+import org.springframework.lang.Nullable;
public class SessionParameterBean {
+ @Nullable
@SessionParameter("annotated_field")
private String annotatedField;
+ @Nullable
private String annotatedSetter;
+ @Nullable
private String annotatedGetter;
+ @Nullable
public String getAnnotatedField() {
return annotatedField;
}
+ @Nullable
@NotEmpty
@SessionParameter("validated")
private String validated;
+ @Nullable
@BeanParameter
private NestedBean nestedBean;
@@ -44,6 +49,7 @@ public void setAnnotatedField(String annotatedField) {
this.annotatedField = annotatedField;
}
+ @Nullable
public String getAnnotatedSetter() {
return annotatedSetter;
}
@@ -53,6 +59,7 @@ public void setAnnotatedSetter(String annotatedSetter) {
this.annotatedSetter = annotatedSetter;
}
+ @Nullable
@SessionParameter("annotated_getter")
public String getAnnotatedGetter() {
return annotatedGetter;
@@ -62,6 +69,7 @@ public void setAnnotatedGetter(String annotatedGetter) {
this.annotatedGetter = annotatedGetter;
}
+ @Nullable
public String getValidated() {
return validated;
}
@@ -70,6 +78,7 @@ public void setValidated(String validated) {
this.validated = validated;
}
+ @Nullable
public NestedBean getNestedBean() {
return nestedBean;
}
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/SessionParameterController.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/SessionParameterController.java
index 14d57ff..10e8b31 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/SessionParameterController.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/SessionParameterController.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,30 +13,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind;
import com.mattbertolini.spring.test.web.bind.records.SessionParameterRecord;
import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
+import jakarta.validation.Valid;
import org.springframework.http.MediaType;
+import org.springframework.lang.Nullable;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
-import javax.validation.Valid;
+import java.util.Objects;
@RestController
public class SessionParameterController {
+ @Nullable
@GetMapping(value = "/annotatedField", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedField(@BeanParameter SessionParameterBean sessionParameterBean) {
return sessionParameterBean.getAnnotatedField();
}
+ @Nullable
@GetMapping(value = "/annotatedSetter", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedSetter(@BeanParameter SessionParameterBean sessionParameterBean) {
return sessionParameterBean.getAnnotatedSetter();
}
+ @Nullable
@GetMapping(value = "/annotatedGetter", produces = MediaType.TEXT_PLAIN_VALUE)
public String annotatedGetter(@BeanParameter SessionParameterBean sessionParameterBean) {
return sessionParameterBean.getAnnotatedGetter();
@@ -47,6 +51,7 @@ public String bindingResult(@BeanParameter SessionParameterBean sessionParameter
return Integer.toString(bindingResult.getErrorCount());
}
+ @Nullable
@GetMapping(value = "/validated", produces = MediaType.TEXT_PLAIN_VALUE)
public String validated(@Valid @BeanParameter SessionParameterBean sessionParameterBean) {
return sessionParameterBean.getValidated();
@@ -60,9 +65,10 @@ public String validatedWithBindingResult(@Valid @BeanParameter SessionParameterB
return "valid";
}
+ @Nullable
@GetMapping(value = "/nested", produces = MediaType.TEXT_PLAIN_VALUE)
public String nestedBean(@BeanParameter SessionParameterBean sessionParameterBean) {
- return sessionParameterBean.getNestedBean().getSessionAttribute();
+ return Objects.requireNonNull(sessionParameterBean.getNestedBean()).getSessionAttribute();
}
@GetMapping(value = "/record", produces = MediaType.TEXT_PLAIN_VALUE)
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/CookieParameterRecord.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/CookieParameterRecord.java
index 3a12092..ce39aeb 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/CookieParameterRecord.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/CookieParameterRecord.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind.records;
import com.mattbertolini.spring.web.bind.annotation.CookieParameter;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/FormParameterRecord.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/FormParameterRecord.java
index f297dc6..f1fbcc3 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/FormParameterRecord.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/FormParameterRecord.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind.records;
import com.mattbertolini.spring.web.bind.annotation.FormParameter;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/HeaderParameterRecord.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/HeaderParameterRecord.java
index d81120f..dd9092c 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/HeaderParameterRecord.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/HeaderParameterRecord.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind.records;
import com.mattbertolini.spring.web.bind.annotation.HeaderParameter;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/PathParameterRecord.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/PathParameterRecord.java
index ae11bee..7f04362 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/PathParameterRecord.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/PathParameterRecord.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind.records;
import com.mattbertolini.spring.web.bind.annotation.PathParameter;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestBodyRecord.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestBodyRecord.java
index fe92418..d6dd140 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestBodyRecord.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestBodyRecord.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind.records;
import com.mattbertolini.spring.test.web.bind.JsonBody;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestContextRecord.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestContextRecord.java
index 69481fe..01ac3ed 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestContextRecord.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestContextRecord.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind.records;
import com.mattbertolini.spring.web.bind.annotation.RequestContext;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestParameterRecord.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestParameterRecord.java
index 4f06f2f..ea685dc 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestParameterRecord.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/RequestParameterRecord.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind.records;
import com.mattbertolini.spring.web.bind.annotation.RequestParameter;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/SessionParameterRecord.java b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/SessionParameterRecord.java
index 10799cc..efd2669 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/SessionParameterRecord.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/test/web/bind/records/SessionParameterRecord.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.test.web.bind.records;
import com.mattbertolini.spring.web.bind.annotation.SessionParameter;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/CookieParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/CookieParameterIntegrationTest.java
index 902b997..baf5900 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/CookieParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/CookieParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.reactive.test;
import com.mattbertolini.spring.test.web.bind.CookieParameterController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/DirectFieldAccessIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/DirectFieldAccessIntegrationTest.java
index 02e6644..362b5e1 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/DirectFieldAccessIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/DirectFieldAccessIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.reactive.test;
import com.mattbertolini.spring.test.web.bind.DirectFieldAccessController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/FormParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/FormParameterIntegrationTest.java
index d1efd7b..0e4359a 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/FormParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/FormParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.reactive.test;
import com.mattbertolini.spring.test.web.bind.FormParameterController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/HeaderParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/HeaderParameterIntegrationTest.java
index 624f085..fe88110 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/HeaderParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/HeaderParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.reactive.test;
import com.mattbertolini.spring.test.web.bind.HeaderParameterController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/PathParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/PathParameterIntegrationTest.java
index 169ccd5..7ac9044 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/PathParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/PathParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.reactive.test;
import com.mattbertolini.spring.test.web.bind.PathParameterController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestBodyIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestBodyIntegrationTest.java
index 9d2b6fd..4f9e342 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestBodyIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestBodyIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.reactive.test;
import com.mattbertolini.spring.test.web.bind.RequestBodyController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestContextIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestContextIntegrationTest.java
index 9c5be22..f6ced5a 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestContextIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestContextIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.reactive.test;
import com.mattbertolini.spring.test.web.bind.RequestContextController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestParameterIntegrationTest.java
index b1d2836..073daad 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/RequestParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.reactive.test;
import com.mattbertolini.spring.test.web.bind.RequestParameterController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionFilter.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionFilter.java
index e2f261f..5424c7d 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionFilter.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionFilter.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.reactive.test;
import org.springframework.lang.NonNull;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionMutator.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionMutator.java
index 11291cb..2bff9ae 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionMutator.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionMutator.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.reactive.test;
import org.springframework.http.client.reactive.ClientHttpConnector;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionParameterIntegrationTest.java
index 0debef3..b730cad 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/reactive/test/SessionParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.reactive.test;
import com.mattbertolini.spring.test.web.bind.SessionParameterController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/CookieParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/CookieParameterIntegrationTest.java
index 17aac83..89dcf5a 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/CookieParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/CookieParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.servlet.mvc.test;
import com.mattbertolini.spring.test.web.bind.CookieParameterController;
import com.mattbertolini.spring.web.servlet.mvc.bind.config.BinderConfiguration;
+import jakarta.servlet.http.Cookie;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Bean;
@@ -30,8 +30,6 @@
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
-import javax.servlet.http.Cookie;
-
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/DirectFieldAccessIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/DirectFieldAccessIntegrationTest.java
index 2af7b3c..d4d62b3 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/DirectFieldAccessIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/DirectFieldAccessIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.servlet.mvc.test;
import com.mattbertolini.spring.test.web.bind.DirectFieldAccessController;
import com.mattbertolini.spring.web.servlet.mvc.bind.config.BinderConfiguration;
+import jakarta.servlet.http.Cookie;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Bean;
@@ -34,8 +34,6 @@
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
-import javax.servlet.http.Cookie;
-
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/FormParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/FormParameterIntegrationTest.java
index b22ad14..43ea0b4 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/FormParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/FormParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.servlet.mvc.test;
import com.mattbertolini.spring.test.web.bind.FormParameterController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/HeaderParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/HeaderParameterIntegrationTest.java
index 4c8fe99..d01e329 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/HeaderParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/HeaderParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.servlet.mvc.test;
import com.mattbertolini.spring.test.web.bind.HeaderParameterController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/PathParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/PathParameterIntegrationTest.java
index b454443..05f546e 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/PathParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/PathParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.servlet.mvc.test;
import com.mattbertolini.spring.test.web.bind.PathParameterController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestBodyIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestBodyIntegrationTest.java
index a406081..39647c3 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestBodyIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestBodyIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.servlet.mvc.test;
import com.mattbertolini.spring.test.web.bind.RequestBodyController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestContextIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestContextIntegrationTest.java
index 29d7743..278d818 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestContextIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestContextIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.servlet.mvc.test;
import com.mattbertolini.spring.test.web.bind.RequestContextController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestParameterIntegrationTest.java
index 29f51af..d4ea073 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/RequestParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.servlet.mvc.test;
import com.mattbertolini.spring.test.web.bind.RequestParameterController;
diff --git a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/SessionParameterIntegrationTest.java b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/SessionParameterIntegrationTest.java
index 87d2983..1aceb35 100644
--- a/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/SessionParameterIntegrationTest.java
+++ b/integration-tests/src/test/java/com/mattbertolini/spring/web/servlet/mvc/test/SessionParameterIntegrationTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.servlet.mvc.test;
import com.mattbertolini.spring.test.web.bind.SessionParameterController;
diff --git a/libs.versions.toml b/libs.versions.toml
index e91f1b7..f8047b9 100644
--- a/libs.versions.toml
+++ b/libs.versions.toml
@@ -1,12 +1,16 @@
[versions]
-spring = "5.3.28" # Used in java-conventions.gradle.kts
-springBoot = "2.7.13" # Used in java-conventions.gradle.kts
+spring = "6.1.10" # Used in java-conventions.gradle.kts
+springBoot = "3.3.1" # Used in java-conventions.gradle.kts
junit = "5.9.3" # Used in java-conventions.gradle.kts
jacoco = "0.8.10" # Used in java-conventions.gradle.kts
+errorProne = "2.29.0"
+nullAway = "0.11.0"
[libraries]
-javaxServletApi = { module = "javax.servlet:javax.servlet-api", version = "4.0.1" }
-javaxValidationApi = { module = "javax.validation:validation-api", version = "2.0.1.Final" }
+jakartaServletApi = { module = "jakarta.servlet:jakarta.servlet-api", version = "6.0.0" }
+jakartaValidationApi = { module = "jakarta.validation:jakarta.validation-api", version = "3.1.0" }
+jakartaWebsocketApi = { module = "jakarta.websocket:jakarta.websocket-api", version = "2.2.0" }
+jakartaWebsocketClientApi = { module = "jakarta.websocket:jakarta.websocket-client-api", version = "2.2.0" }
findbugsJsr305 = { module = "com.google.code.findbugs:jsr305", version = "3.0.2" }
@@ -22,9 +26,9 @@ springBootTest = { module = "org.springframework.boot:spring-boot-test", version
springAsciidoctorExtBlockSwitch = { module = "io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch", version = "0.6.1" }
-glassfishJavaxEl = { module = "org.glassfish:javax.el", version = "3.0.1-b12" } # Needed by Hibernate Validator
-hibernateValidator = { module = "org.hibernate.validator:hibernate-validator", version = "6.0.21.Final" }
-jacksonDatabind = { module = "com.fasterxml.jackson.core:jackson-databind", version = "2.12.7.1" }
+glassfishJakartaEl = { module = "org.glassfish:jakarta.el", version = "4.0.2" } # Needed by Hibernate Validator
+hibernateValidator = { module = "org.hibernate.validator:hibernate-validator", version = "8.0.1.Final" }
+jacksonDatabind = { module = "com.fasterxml.jackson.core:jackson-databind", version = "2.17.2" }
junitJupiterApi = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
assertJCore = { module = "org.assertj:assertj-core", version = "3.24.2" }
@@ -32,6 +36,11 @@ mockitoCore = { module = "org.mockito:mockito-core", version = "5.3.1" }
equalsVerifier = { module = "nl.jqno.equalsverifier:equalsverifier", version = "3.14.2" }
hamcrest = { module = "org.hamcrest:hamcrest", version = "2.2" }
+errorProneCore = { module = "com.google.errorprone:error_prone_core", version.ref = "errorProne" }
+errorProneAnnotations = { module = "com.google.errorprone:error_prone_annotations", version.ref = "errorProne"}
+nullAway = { module = "com.uber.nullaway:nullaway", version.ref = "nullAway" }
+nullAwayAnnotations = { module = "com.uber.nullaway:nullaway-annotations", version.ref = "nullAway" }
+
[plugins]
asciidoctorConvert = { id = "org.asciidoctor.jvm.convert", version = "3.3.2" }
sonarqube = { id = "org.sonarqube", version = "5.0.0.4638" }
\ No newline at end of file
diff --git a/publish.sh b/publish.sh
old mode 100644
new mode 100755
index c116e88..dedec2d
--- a/publish.sh
+++ b/publish.sh
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
# Disabling parallel builds as it doesn't work when publishing to Maven Central
-./gradlew --no-parallel build publish
\ No newline at end of file
+./gradlew --no-parallel --no-configuration-cache build publish
\ No newline at end of file
diff --git a/spring-annotated-data-binder-core/build.gradle.kts b/spring-annotated-data-binder-core/build.gradle.kts
index 8a644b6..df52b27 100644
--- a/spring-annotated-data-binder-core/build.gradle.kts
+++ b/spring-annotated-data-binder-core/build.gradle.kts
@@ -8,13 +8,14 @@ dependencies {
api(libs.springBeans)
api(libs.springWeb)
compileOnly(libs.findbugsJsr305) // To Prevent warnings on missing enum constants
- compileOnly(libs.javaxServletApi) // So Javadoc doesn't give warnings about missing links
+ compileOnly(libs.jakartaServletApi) // So Javadoc doesn't give warnings about missing links
testImplementation(libs.junitJupiterApi)
testImplementation(libs.assertJCore)
testImplementation(libs.mockitoCore)
testImplementation(libs.springTest)
testImplementation(libs.equalsVerifier)
+ testCompileOnly(libs.findbugsJsr305)
}
tasks.named("jar").configure {
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/AbstractPropertyResolverRegistry.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/AbstractPropertyResolverRegistry.java
index c466838..a6dd6d1 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/AbstractPropertyResolverRegistry.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/AbstractPropertyResolverRegistry.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2021 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,12 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind;
import com.mattbertolini.spring.web.bind.introspect.BindingProperty;
import com.mattbertolini.spring.web.bind.resolver.RequestPropertyResolverBase;
-import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import java.util.Collections;
@@ -38,7 +36,7 @@ protected AbstractPropertyResolverRegistry() {
}
@Nullable
- public T findResolverFor(@NonNull BindingProperty bindingProperty) {
+ public T findResolverFor(BindingProperty bindingProperty) {
for (T resolver : propertyResolvers) {
if (resolver.supports(bindingProperty)) {
return resolver;
@@ -77,7 +75,6 @@ public void addResolvers(AbstractPropertyResolverRegistry registry) {
/**
* Returns an unmodifiable collection of the resolvers.
*/
- @NonNull
public Set getPropertyResolvers() {
return Collections.unmodifiableSet(propertyResolvers);
}
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/PropertyResolutionException.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/PropertyResolutionException.java
index 614bfae..c658a6f 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/PropertyResolutionException.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/PropertyResolutionException.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind;
/**
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/RequestPropertyBindingException.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/RequestPropertyBindingException.java
index a5c553e..bfec84f 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/RequestPropertyBindingException.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/RequestPropertyBindingException.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind;
public class RequestPropertyBindingException extends RuntimeException {
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/BeanParameter.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/BeanParameter.java
index ea311a7..571e026 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/BeanParameter.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/BeanParameter.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.annotation;
import java.lang.annotation.Documented;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/CookieParameter.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/CookieParameter.java
index f140ac1..afc9370 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/CookieParameter.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/CookieParameter.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.annotation;
import java.lang.annotation.Documented;
@@ -40,7 +39,7 @@
*
*
*
If you need access to all attributes of a cookie (e.g. expiration date, domain, etc) you can bind to cookie
- * objects. In Spring MVC you and bind directly to a {@link javax.servlet.http.Cookie}:
+ * objects. In Spring MVC you and bind directly to a {@link jakarta.servlet.http.Cookie}:
*
{@code
* @CookieParameter("cookie_name")
* private Cookie cookie;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/FormParameter.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/FormParameter.java
index 430bb20..22de602 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/FormParameter.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/FormParameter.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.annotation;
import java.lang.annotation.Documented;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/HeaderParameter.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/HeaderParameter.java
index eb00ef4..36dbff1 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/HeaderParameter.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/HeaderParameter.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.annotation;
import java.lang.annotation.Documented;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/PathParameter.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/PathParameter.java
index 7658576..e5522b9 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/PathParameter.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/PathParameter.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.annotation;
import java.lang.annotation.Documented;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestBean.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestBean.java
index e13df18..57c5153 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestBean.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestBean.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.annotation;
import java.lang.annotation.Documented;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestBody.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestBody.java
index 367ef91..9acb239 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestBody.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestBody.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.annotation;
import java.lang.annotation.Documented;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestContext.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestContext.java
index c77a55e..eea5d95 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestContext.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestContext.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.annotation;
import java.lang.annotation.Documented;
@@ -33,8 +32,8 @@
* In Spring MVC the following additional objects are available:
*
*
{@link org.springframework.web.context.request.WebRequest} - The Spring WebRequest.
- *
{@link javax.servlet.http.HttpServletRequest} - The underlying Servlet request.
- *
{@link javax.servlet.http.HttpSession} - The Servlet session object.
+ *
{@link jakarta.servlet.http.HttpServletRequest} - The underlying Servlet request.
+ *
{@link jakarta.servlet.http.HttpSession} - The Servlet session object.
*
* In Spring WebFlux the following additional objects are available:
*
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestParameter.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestParameter.java
index d284a89..fe15359 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestParameter.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/RequestParameter.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.annotation;
import java.lang.annotation.Documented;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/SessionParameter.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/SessionParameter.java
index 1d2b465..158229c 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/SessionParameter.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/SessionParameter.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.annotation;
import java.lang.annotation.Documented;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/package-info.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/package-info.java
new file mode 100644
index 0000000..91f6d2c
--- /dev/null
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/annotation/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2024 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
+ *
+ * http://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.
+ */
+@NonNullApi
+@NonNullFields
+package com.mattbertolini.spring.web.bind.annotation;
+
+import org.springframework.lang.NonNullApi;
+import org.springframework.lang.NonNullFields;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/AnnotatedRequestBeanIntrospector.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/AnnotatedRequestBeanIntrospector.java
index 501ef87..df9b38f 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/AnnotatedRequestBeanIntrospector.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/AnnotatedRequestBeanIntrospector.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,11 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.introspect;
-import org.springframework.lang.NonNull;
-
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -32,8 +29,7 @@ public interface AnnotatedRequestBeanIntrospector {
* @return A map of resolved property data. This map is never null but may be empty.
* @throws CircularReferenceException If a circular reference is found while traversing the object graph.
*/
- @NonNull
- Map getResolverMapFor(@NonNull Class> targetType);
+ Map getResolverMapFor(Class> targetType);
/**
* Creates a list of resolved property data for the given target class. This method traverses the object graph for
@@ -43,8 +39,7 @@ public interface AnnotatedRequestBeanIntrospector {
* @return A list of resolved property data. This list is never null but may be empty.
* @throws CircularReferenceException If a circular reference is found while traversing the object graph.
*/
- @NonNull
- default Collection getResolversFor(@NonNull Class> targetType) {
+ default Collection getResolversFor(Class> targetType) {
Map propertyData = getResolverMapFor(targetType);
return Collections.unmodifiableCollection(propertyData.values());
}
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/BindingProperty.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/BindingProperty.java
index 357e637..2efe4e6 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/BindingProperty.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/BindingProperty.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,13 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.introspect;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.Property;
import org.springframework.core.convert.TypeDescriptor;
-import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import java.beans.PropertyDescriptor;
@@ -35,7 +33,7 @@ public final class BindingProperty {
private final TypeDescriptor typeDescriptor;
private final MethodParameter methodParameter;
- private BindingProperty(@NonNull TypeDescriptor typeDescriptor, @NonNull MethodParameter methodParameter) {
+ private BindingProperty(TypeDescriptor typeDescriptor, MethodParameter methodParameter) {
this.typeDescriptor = typeDescriptor;
this.methodParameter = methodParameter;
}
@@ -45,7 +43,6 @@ public T getAnnotation(Class annotationType) {
return typeDescriptor.getAnnotation(annotationType);
}
- @NonNull
public MethodParameter getMethodParameter() {
return methodParameter;
}
@@ -69,8 +66,7 @@ public boolean hasAnnotation(Class extends Annotation> annotationType) {
* @param propertyDescriptor The Java Beans PropertyDescriptor to create a BindingProperty for.
* @return A new BindingProperty object.
*/
- @NonNull
- public static BindingProperty forPropertyDescriptor(@NonNull PropertyDescriptor propertyDescriptor) {
+ public static BindingProperty forPropertyDescriptor(PropertyDescriptor propertyDescriptor) {
Property property = new Property(
propertyDescriptor.getPropertyType(),
propertyDescriptor.getReadMethod(),
@@ -86,8 +82,7 @@ public static BindingProperty forPropertyDescriptor(@NonNull PropertyDescriptor
* This method is more or less the same as found in {@link Property} but those are not exposed publicly so I
* needed to replicate it.
*/
- @NonNull
- private static MethodParameter resolveMethodParameter(@NonNull Property property) {
+ private static MethodParameter resolveMethodParameter(Property property) {
MethodParameter readMethodParameter = resolveReadMethodParameter(property);
MethodParameter writeMethodParameter = resolveWriteMethodParameter(property);
if (writeMethodParameter == null) {
@@ -107,7 +102,7 @@ private static MethodParameter resolveMethodParameter(@NonNull Property property
}
@Nullable
- private static MethodParameter resolveReadMethodParameter(@NonNull Property property) {
+ private static MethodParameter resolveReadMethodParameter(Property property) {
if (property.getReadMethod() == null) {
return null;
}
@@ -115,7 +110,7 @@ private static MethodParameter resolveReadMethodParameter(@NonNull Property prop
}
@Nullable
- private static MethodParameter resolveWriteMethodParameter(@NonNull Property property) {
+ private static MethodParameter resolveWriteMethodParameter(Property property) {
if (property.getWriteMethod() == null) {
return null;
}
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/CachedAnnotatedRequestBeanIntrospector.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/CachedAnnotatedRequestBeanIntrospector.java
index 6ac201e..948e329 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/CachedAnnotatedRequestBeanIntrospector.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/CachedAnnotatedRequestBeanIntrospector.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,11 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.introspect;
-import org.springframework.lang.NonNull;
-
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -26,14 +23,13 @@ public class CachedAnnotatedRequestBeanIntrospector implements AnnotatedRequestB
private final AnnotatedRequestBeanIntrospector delegate;
private final ConcurrentMap, Map> cache;
- public CachedAnnotatedRequestBeanIntrospector(@NonNull AnnotatedRequestBeanIntrospector delegate) {
+ public CachedAnnotatedRequestBeanIntrospector(AnnotatedRequestBeanIntrospector delegate) {
this.delegate = delegate;
cache = new ConcurrentHashMap<>();
}
@Override
- @NonNull
- public Map getResolverMapFor(@NonNull Class> targetType) {
+ public Map getResolverMapFor(Class> targetType) {
return cache.computeIfAbsent(targetType, delegate::getResolverMapFor);
}
}
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/CircularReferenceException.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/CircularReferenceException.java
index d728f97..c48b717 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/CircularReferenceException.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/CircularReferenceException.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.introspect;
/**
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/ClassPathScanningAnnotatedRequestBeanIntrospector.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/ClassPathScanningAnnotatedRequestBeanIntrospector.java
index 2a64fb4..66225de 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/ClassPathScanningAnnotatedRequestBeanIntrospector.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/ClassPathScanningAnnotatedRequestBeanIntrospector.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.introspect;
import com.mattbertolini.spring.web.bind.annotation.RequestBean;
@@ -23,7 +22,6 @@
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AnnotationTypeFilter;
-import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
@@ -39,7 +37,7 @@ public class ClassPathScanningAnnotatedRequestBeanIntrospector implements Annota
private final CachedAnnotatedRequestBeanIntrospector introspectorCache;
private final Set basePackages;
- public ClassPathScanningAnnotatedRequestBeanIntrospector(@NonNull AnnotatedRequestBeanIntrospector delegate, @Nullable Set basePackages) {
+ public ClassPathScanningAnnotatedRequestBeanIntrospector(AnnotatedRequestBeanIntrospector delegate, @Nullable Set basePackages) {
this.basePackages = new HashSet<>();
if (basePackages != null) {
this.basePackages.addAll(basePackages);
@@ -50,8 +48,7 @@ public ClassPathScanningAnnotatedRequestBeanIntrospector(@NonNull AnnotatedReque
}
@Override
- @NonNull
- public Map getResolverMapFor(@NonNull Class> targetType) {
+ public Map getResolverMapFor(Class> targetType) {
return introspectorCache.getResolverMapFor(targetType);
}
@@ -62,7 +59,7 @@ public void afterPropertiesSet() {
}
}
- private void scanAndLoadRequestBeans(@NonNull String basePackage) {
+ private void scanAndLoadRequestBeans(String basePackage) {
ClassLoader classLoader = ClassPathScanningAnnotatedRequestBeanIntrospector.class.getClassLoader();
LOGGER.debug("Searching for @RequestBean annotated classes in package [" + basePackage + "]");
Set candidateComponents = scanner.findCandidateComponents(basePackage);
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/DefaultAnnotatedRequestBeanIntrospector.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/DefaultAnnotatedRequestBeanIntrospector.java
index c7d04b9..ac8f23c 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/DefaultAnnotatedRequestBeanIntrospector.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/DefaultAnnotatedRequestBeanIntrospector.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2022 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.introspect;
import com.mattbertolini.spring.web.bind.AbstractPropertyResolverRegistry;
@@ -21,7 +20,6 @@
import com.mattbertolini.spring.web.bind.resolver.RequestPropertyResolverBase;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
-import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import java.beans.PropertyDescriptor;
@@ -39,7 +37,7 @@ public class DefaultAnnotatedRequestBeanIntrospector implements AnnotatedRequest
private final AbstractPropertyResolverRegistry> registry;
- public DefaultAnnotatedRequestBeanIntrospector(@NonNull AbstractPropertyResolverRegistry> registry) {
+ public DefaultAnnotatedRequestBeanIntrospector(AbstractPropertyResolverRegistry> registry) {
this.registry = registry;
}
@@ -52,18 +50,17 @@ public DefaultAnnotatedRequestBeanIntrospector(@NonNull AbstractPropertyResolver
* @throws CircularReferenceException If a circular reference is found while traversing the object graph.
*/
@Override
- @NonNull
- public Map getResolverMapFor(@NonNull Class> targetType) {
+ public Map getResolverMapFor(Class> targetType) {
Set> cycleClasses = new LinkedHashSet<>();
Map propertyData = new HashMap<>();
recursiveGetResolverMapFor(targetType, null, propertyData, cycleClasses);
return Collections.unmodifiableMap(propertyData);
}
- private void recursiveGetResolverMapFor(@NonNull final Class> targetType,
+ private void recursiveGetResolverMapFor(final Class> targetType,
@Nullable final String prefix,
- @NonNull Map propertyData,
- @NonNull final Set> cycleClasses) {
+ Map propertyData,
+ final Set> cycleClasses) {
PropertyDescriptor[] propertyDescriptors;
try {
propertyDescriptors = BeanUtils.getPropertyDescriptors(targetType);
@@ -102,7 +99,7 @@ private void recursiveGetResolverMapFor(@NonNull final Class> targetType,
* @param propertyDescriptor The property descriptor to find a name for. Required.
* @return The full property name path
*/
- private String getPropertyName(@Nullable String prefix, @NonNull PropertyDescriptor propertyDescriptor) {
+ private String getPropertyName(@Nullable String prefix, PropertyDescriptor propertyDescriptor) {
if (prefix == null) {
return propertyDescriptor.getName();
}
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/RequestBeanIntrospectionException.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/RequestBeanIntrospectionException.java
index e18a058..a12d284 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/RequestBeanIntrospectionException.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/RequestBeanIntrospectionException.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.introspect;
public class RequestBeanIntrospectionException extends RuntimeException {
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/ResolvedPropertyData.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/ResolvedPropertyData.java
index d2e236c..d9b84cb 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/ResolvedPropertyData.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/ResolvedPropertyData.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,60 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.introspect;
import com.mattbertolini.spring.web.bind.resolver.RequestPropertyResolverBase;
-import org.springframework.lang.NonNull;
-
-import java.util.Objects;
-
-public final class ResolvedPropertyData {
- private final String propertyName;
- private final BindingProperty bindingProperty;
- private final RequestPropertyResolverBase, ?> resolver;
-
- public ResolvedPropertyData(
- @NonNull String propertyName,
- @NonNull BindingProperty bindingProperty,
- @NonNull RequestPropertyResolverBase, ?> resolver
- ) {
- this.propertyName = propertyName;
- this.bindingProperty = bindingProperty;
- this.resolver = resolver;
- }
-
- @NonNull
- public String getPropertyName() {
- return propertyName;
- }
-
- @NonNull
- public BindingProperty getBindingProperty() {
- return bindingProperty;
- }
-
- @NonNull
- public RequestPropertyResolverBase, ?> getResolver() {
- return resolver;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof ResolvedPropertyData)) {
- return false;
- }
- ResolvedPropertyData that = (ResolvedPropertyData) o;
- return Objects.equals(propertyName, that.propertyName) &&
- Objects.equals(bindingProperty, that.bindingProperty) &&
- Objects.equals(resolver, that.resolver);
- }
- @Override
- public int hashCode() {
- return Objects.hash(propertyName, bindingProperty, resolver);
- }
-}
+public record ResolvedPropertyData(
+ String propertyName,
+ BindingProperty bindingProperty,
+ RequestPropertyResolverBase, ?> resolver) {}
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/package-info.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/package-info.java
new file mode 100644
index 0000000..7023dc6
--- /dev/null
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/introspect/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2024 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
+ *
+ * http://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.
+ */
+@NonNullApi
+@NonNullFields
+package com.mattbertolini.spring.web.bind.introspect;
+
+import org.springframework.lang.NonNullApi;
+import org.springframework.lang.NonNullFields;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/package-info.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/package-info.java
new file mode 100644
index 0000000..a2a7d09
--- /dev/null
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2024 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
+ *
+ * http://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.
+ */
+@NonNullApi
+@NonNullFields
+package com.mattbertolini.spring.web.bind;
+
+import org.springframework.lang.NonNullApi;
+import org.springframework.lang.NonNullFields;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/resolver/AbstractNamedRequestPropertyResolver.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/resolver/AbstractNamedRequestPropertyResolver.java
index f66d9cd..ef681b9 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/resolver/AbstractNamedRequestPropertyResolver.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/resolver/AbstractNamedRequestPropertyResolver.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,21 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.resolver;
import com.mattbertolini.spring.web.bind.introspect.BindingProperty;
-import org.springframework.lang.NonNull;
+import org.springframework.lang.Nullable;
public abstract class AbstractNamedRequestPropertyResolver implements RequestPropertyResolverBase {
- @NonNull
- protected abstract String getName(@NonNull BindingProperty bindingProperty);
+ protected abstract String getName(BindingProperty bindingProperty);
@Override
- public final R resolve(@NonNull BindingProperty bindingProperty, @NonNull T request) {
+ @Nullable
+ public final R resolve(BindingProperty bindingProperty, T request) {
String name = getName(bindingProperty);
return resolveWithName(bindingProperty, name, request);
}
- protected abstract R resolveWithName(@NonNull BindingProperty bindingProperty, String name, @NonNull T request);
+ @Nullable
+ protected abstract R resolveWithName(BindingProperty bindingProperty, String name, T request);
}
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/resolver/RequestPropertyResolverBase.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/resolver/RequestPropertyResolverBase.java
index 2dc977b..eff6e55 100644
--- a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/resolver/RequestPropertyResolverBase.java
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/resolver/RequestPropertyResolverBase.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,11 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.resolver;
import com.mattbertolini.spring.web.bind.introspect.BindingProperty;
-import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
/**
@@ -28,8 +26,8 @@
* @param The response type to use.
*/
public interface RequestPropertyResolverBase {
- boolean supports(@NonNull BindingProperty bindingProperty);
+ boolean supports(BindingProperty bindingProperty);
@Nullable
- R resolve(@NonNull BindingProperty bindingProperty, @NonNull T request);
+ R resolve(BindingProperty bindingProperty, T request);
}
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/resolver/package-info.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/resolver/package-info.java
new file mode 100644
index 0000000..2ba5338
--- /dev/null
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/resolver/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2024 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
+ *
+ * http://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.
+ */
+@NonNullApi
+@NonNullFields
+package com.mattbertolini.spring.web.bind.resolver;
+
+import org.springframework.lang.NonNullApi;
+import org.springframework.lang.NonNullFields;
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/support/MapValueResolver.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/support/MapValueResolver.java
new file mode 100644
index 0000000..5e0376c
--- /dev/null
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/support/MapValueResolver.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2024 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
+ *
+ * http://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 com.mattbertolini.spring.web.bind.support;
+
+import org.springframework.lang.Nullable;
+import org.springframework.validation.DataBinder;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Implementation of the {@link DataBinder.ValueResolver} to assist in mapping binding data for constructor binding.
+ *
+ * @param values The Map of values to pass to the binder
+ */
+public record MapValueResolver(Map values) implements DataBinder.ValueResolver {
+ @Override
+ @Nullable
+ public Object resolveValue(String name, Class> type) {
+ return values.get(name);
+ }
+
+ @Override
+ public Set getNames() {
+ return Set.copyOf(values.keySet());
+ }
+
+ @Override
+ public Map values() {
+ return Collections.unmodifiableMap(values);
+ }
+}
diff --git a/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/support/package-info.java b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/support/package-info.java
new file mode 100644
index 0000000..12ee672
--- /dev/null
+++ b/spring-annotated-data-binder-core/src/main/java/com/mattbertolini/spring/web/bind/support/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2024 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
+ *
+ * http://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.
+ */
+@NonNullApi
+@NonNullFields
+package com.mattbertolini.spring.web.bind.support;
+
+import org.springframework.lang.NonNullApi;
+import org.springframework.lang.NonNullFields;
diff --git a/spring-annotated-data-binder-core/src/test/java/com/mattbertolini/spring/web/bind/AbstractPropertyResolverRegistryTest.java b/spring-annotated-data-binder-core/src/test/java/com/mattbertolini/spring/web/bind/AbstractPropertyResolverRegistryTest.java
index 494e68e..bba94e6 100644
--- a/spring-annotated-data-binder-core/src/test/java/com/mattbertolini/spring/web/bind/AbstractPropertyResolverRegistryTest.java
+++ b/spring-annotated-data-binder-core/src/test/java/com/mattbertolini/spring/web/bind/AbstractPropertyResolverRegistryTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind;
import com.mattbertolini.spring.web.bind.introspect.BindingProperty;
import com.mattbertolini.spring.web.bind.resolver.RequestPropertyResolverBase;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.springframework.lang.Nullable;
import java.beans.PropertyDescriptor;
import java.util.Collections;
@@ -100,8 +100,10 @@ private static class TestingRegistry extends AbstractPropertyResolverRegistry resolvers = introspector.getResolversFor(SimpleType.class);
assertThat(resolvers).hasSize(1);
ResolvedPropertyData data = resolvers.iterator().next();
- assertThat(data.getPropertyName()).isEqualTo("data");
+ assertThat(data.propertyName()).isEqualTo("data");
}
@Test
@@ -63,7 +62,7 @@ void returnsResolversUsingNestedTypes() {
Collection resolvers = introspector.getResolversFor(OuterBean.class);
assertThat(resolvers).hasSize(1);
ResolvedPropertyData data = resolvers.iterator().next();
- assertThat(data.getPropertyName()).isEqualTo("innerBean.inner");
+ assertThat(data.propertyName()).isEqualTo("innerBean.inner");
}
private static class FakeResolver implements RequestPropertyResolverBase {
@@ -74,12 +73,13 @@ public FakeResolver(Class extends Annotation> annotationType) {
}
@Override
- public boolean supports(@NonNull BindingProperty bindingProperty) {
+ public boolean supports(BindingProperty bindingProperty) {
return bindingProperty.hasAnnotation(annotationType);
}
@Override
- public Object resolve(@NonNull BindingProperty bindingProperty, @NonNull Void request) {
+ @Nullable
+ public Object resolve(BindingProperty bindingProperty, Void request) {
// Don't need to worry about this method. No used in the introspector.
return null;
}
@@ -93,9 +93,11 @@ public FakeRegistry() {
@SuppressWarnings("unused")
private static class SimpleType {
+ @Nullable
@RequestParameter("data_param")
private String data;
+ @Nullable
public String getData() {
return data;
}
@@ -107,9 +109,11 @@ public void setData(String data) {
@SuppressWarnings("unused")
private static class OuterBean {
+ @Nullable
@BeanParameter
private InnerBean innerBean;
+ @Nullable
public InnerBean getInnerBean() {
return innerBean;
}
@@ -121,9 +125,11 @@ public void setInnerBean(InnerBean innerBean) {
@SuppressWarnings("unused")
private static class InnerBean {
+ @Nullable
@RequestParameter("inner_param")
private String inner;
+ @Nullable
public String getInner() {
return inner;
}
@@ -135,9 +141,11 @@ public void setInner(String inner) {
@SuppressWarnings("unused")
private static class CircularReference {
+ @Nullable
@BeanParameter
private CircularReference circularReference;
+ @Nullable
public CircularReference getCircularReference() {
return circularReference;
}
diff --git a/spring-annotated-data-binder-core/src/test/java/com/mattbertolini/spring/web/bind/introspect/ResolvedPropertyDataTest.java b/spring-annotated-data-binder-core/src/test/java/com/mattbertolini/spring/web/bind/introspect/ResolvedPropertyDataTest.java
index 78a7f32..f6737ea 100644
--- a/spring-annotated-data-binder-core/src/test/java/com/mattbertolini/spring/web/bind/introspect/ResolvedPropertyDataTest.java
+++ b/spring-annotated-data-binder-core/src/test/java/com/mattbertolini/spring/web/bind/introspect/ResolvedPropertyDataTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2019-2020 the original author or authors.
+ * Copyright 2024 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
+ * http://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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.mattbertolini.spring.web.bind.introspect;
import com.mattbertolini.spring.web.bind.resolver.RequestPropertyResolverBase;
@@ -21,7 +20,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.TypeDescriptor;
-import org.springframework.lang.NonNull;
+import org.springframework.lang.Nullable;
import java.beans.PropertyDescriptor;
@@ -40,20 +39,20 @@ void setUp() throws Exception {
@Test
void returnsPropertyName() {
- assertThat(propertyData.getPropertyName()).isEqualTo("name");
+ assertThat(propertyData.propertyName()).isEqualTo("name");
}
@Test
void returnsBindingProperty() throws Exception {
BindingProperty expected = BindingProperty.forPropertyDescriptor(
new PropertyDescriptor("property", TestingClass.class));
- assertThat(propertyData.getBindingProperty()).isEqualTo(expected);
+ assertThat(propertyData.bindingProperty()).isEqualTo(expected);
}
@Test
void returnsResolver() {
- assertThat(propertyData.getResolver()).isNotNull();
- assertThat(propertyData.getResolver()).isInstanceOf(StubResolver.class);
+ assertThat(propertyData.resolver()).isNotNull();
+ assertThat(propertyData.resolver()).isInstanceOf(StubResolver.class);
}
@Test
@@ -69,22 +68,26 @@ void equalsContract() throws Exception {
private static class StubResolver implements RequestPropertyResolverBase