Skip to content

fix: replace boilerplate code and consolidate common classes#362

Merged
gkc merged 1 commit intotrunkfrom
remove_boilerplate
Feb 23, 2026
Merged

fix: replace boilerplate code and consolidate common classes#362
gkc merged 1 commit intotrunkfrom
remove_boilerplate

Conversation

@akafredperry
Copy link
Collaborator

@akafredperry akafredperry commented Feb 23, 2026

closes #323

- What I did

  • Removed "boiler plate" Java code where possible
  • Converted Key classes and Metadata class to immutable classes.
  • Consolidated KeyStringUtil.java and KeyBuilders.java into Keys.java
  • Builders are now always "fluent api" style
  • Improved preconditions (so that builders throw exceptions rather than generate invalid results)
  • Improved Unit test coverage (the classes I touched no longer rely on end to end tests for coverage)
  • Addressed thread safety of Metadata changes

- How I did it

  • Metadata is now an immutable class with private fields. None of the fields have defaults anymore. The getter methods use the "fluent api" style. There is a corresponding builder class MetadataBuilder. Metadata has a toBuilder() method to help creating modified metadata instances and the static method toMergedBuilder replicates the squash() for combining the fields of two metadata instances. Where possible Lombok has been used to remove boiler plate code.
  • The abstract class AtKey is now immutable (other than the metadata field) with private fields. The getter methods use the "fluent api" style. There are two methods for updating the medata field. One which will update unset fields and one which will overwrite. Each of the subclasses now has a corresponding builder and this is the only way to construct instances. These are all Lombok builders "backed by" a static method. These replace KeyBuilders.java. Additionally there is a builder that will construct AtKey subclasses from a "raw key" (the fully qualified key string), this replaces KeyStringUtil.java.
  • VerbBuilders have been completely re-written to use Lombok builders ("backed by" static methods). This class covers all command string composition in at_java and any code that was previously composing comand strings directly now uses the appropriate builder.
  • Atsign is now a Typed String class
  • "Well known" key names have been consolidated in AtKeyNames.java

NOTES: #363 collates suggestions on further refactoring which should be done separately from this issue (to help review)

- How to verify it

  • Runs the unit and integration tests
mvn clean install

- Description for the changelog

make Keys and Metadata immutable and remove boiler plate code

@akafredperry akafredperry marked this pull request as ready for review February 23, 2026 12:23
@akafredperry akafredperry requested a review from gkc February 23, 2026 12:23
Copy link
Contributor

@gkc gkc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thank you @akafredperry

@gkc gkc merged commit c0b7c7d into trunk Feb 23, 2026
4 checks passed
@gkc gkc deleted the remove_boilerplate branch February 23, 2026 14:45
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.

Remove boiler plate Java code

2 participants