Skip to content

Optimize handling of Optionals in Java - #893

Open
empwilli wants to merge 5 commits into
mainfrom
empwilli/improve_optional_handling_java
Open

empwilli wants to merge 5 commits into
mainfrom
empwilli/improve_optional_handling_java

Conversation

@empwilli

Copy link
Copy Markdown
Contributor

The java code internally would wrap/unwrap optional properties multiple
times. Introduce temporary variables & lambda accessors to skip these
wrap/unwrap calls and prevent the associated allocations.

Until now the code generation for Java did not emit empty constructors.
As Java does not permit to elide optional arguments, this made the
construction of classes with only optional attributes tedious: users
either had to use builders, or they had to provide a series of "null"
values on construction. Furthermore, the pattern was inconsistent with
how parameters are handled in general: we already generate constructors
with only mandatory parameters, leaving out the optional ones. With this
we address the issue and additionally generate empty constructors for
classes for that all attributes are optinal.
With more recent versions of `com.fasterxml.jackson.core` the `fields()`
accessor for json nodes has become deprecated. Instead, these the
properties are now accessible via the `properties()` method. Adapt the
code generation accordingly.
The java doc comments for XmlCommon contained a broken link to a generic
group of functions. This caused the documentation publishing step to
break. Replace the link with rendering in mono-space font.
Due to a missing import, the docs generation for Java failed, as a type
referenced in the doc comments was unknown.
The java code internally would wrap/unwrap optional properties multiple
times. Introduce temporary variables & lambda accessors to skip these
wrap/unwrap calls and prevent the associated allocations.
@empwilli
empwilli requested a review from mristin November 18, 2026 14:03
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 44320099494

Coverage increased (+0.005%) to 90.324%

Details

  • Coverage increased (+0.005%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (44 of 45 lines covered, 97.78%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
aas_core_codegen/java/lib/_generate_verification.py 40 39 97.5%
Total (2 files) 45 44 97.78%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 52397
Covered Lines: 47327
Line Coverage: 90.32%
Coverage Strength: 2.71 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants