From 1fce408b6a255444143c9564b0a69044f023cbb2 Mon Sep 17 00:00:00 2001 From: macklee Date: Mon, 11 Sep 2023 11:46:15 -0500 Subject: [PATCH] Add @Nullable annotations for pegasus java getters and setters with mode (#932) --- CHANGELOG.md | 6 +++++- .../pegasus/generator/JavaDataTemplateGenerator.java | 2 ++ gradle.properties | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2ee1b2ecc..f90c073212 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and what APIs have changed, if applicable. ## [Unreleased] +## [29.45.1] - 2023-09-05 +- add @Nullable annotations to pegasus java getters and setters with mode + ## [29.45.0] - 2023-08-25 - Downgrade major version back to 29. Technically this is not semver-compatible @@ -5524,7 +5527,8 @@ patch operations can re-use these classes for generating patch messages. ## [0.14.1] -[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.45.0...master +[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.45.1...master +[29.45.1]: https://github.com/linkedin/rest.li/compare/v29.45.0...v29.45.1 [29.45.0]: https://github.com/linkedin/rest.li/compare/v30.0.0...v29.45.0 [30.0.0]: https://github.com/linkedin/rest.li/compare/v29.44.0...v30.0.0 [29.44.0]: https://github.com/linkedin/rest.li/compare/v29.43.11...v29.44.0 diff --git a/generator/src/main/java/com/linkedin/pegasus/generator/JavaDataTemplateGenerator.java b/generator/src/main/java/com/linkedin/pegasus/generator/JavaDataTemplateGenerator.java index f23f44a516..cfdbf8b169 100644 --- a/generator/src/main/java/com/linkedin/pegasus/generator/JavaDataTemplateGenerator.java +++ b/generator/src/main/java/com/linkedin/pegasus/generator/JavaDataTemplateGenerator.java @@ -1119,6 +1119,7 @@ private void generateRecordFieldAccessors(JDefinedClass templateClass, RecordTem final JMethod getterWithMode = templateClass.method(JMod.PUBLIC, type, getterName); addAccessorDoc(templateClass, getterWithMode, schemaField, "Getter"); setDeprecatedAnnotationAndJavadoc(getterWithMode, schemaField); + getterWithMode.annotate(Nullable.class); JVar modeParam = getterWithMode.param(_getModeClass, "mode"); final JBlock getterWithModeBody = getterWithMode.body(); @@ -1200,6 +1201,7 @@ else if (!schemaField.getOptional()) addAccessorDoc(templateClass, setterWithMode, schemaField, "Setter"); setDeprecatedAnnotationAndJavadoc(setterWithMode, schemaField); JVar param = setterWithMode.param(type, "value"); + param.annotate(Nullable.class); JVar modeParam = setterWithMode.param(_setModeClass, "mode"); JSwitch modeSwitch = setterWithMode.body()._switch(modeParam); JCase disallowNullCase = modeSwitch._case(JExpr.ref("DISALLOW_NULL")); diff --git a/gradle.properties b/gradle.properties index e8687a643d..7e1b97036b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=29.45.0 +version=29.45.1 group=com.linkedin.pegasus org.gradle.configureondemand=true org.gradle.parallel=true