metaschema-framework / metaschema-java

https://metaschema-java.metaschema.dev/
Other
0 stars 3 forks source link

More code cleanup and refactoring #245

Open david-waltermire opened 3 days ago

david-waltermire commented 3 days ago

Committer Notes

Adding Javadocs; addressing compile, PMD, and spotbugs warnings; and refactoring code for better organization and easier maintenance.

These changes include:

All Submissions:

By submitting a pull request, you are agreeing to provide this contribution under the CC0 1.0 Universal public domain dedication.

Changes to Core Features:

Summary by CodeRabbit

coderabbitai[bot] commented 3 days ago

[!IMPORTANT]

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough ## Walkthrough The changes in this pull request involve modifications across various classes and interfaces within the Metaschema framework. Key alterations include changing the visibility of static fields in `MetaschemaJavaVersion` and `MetaschemaVersion` from public to private, enhancing encapsulation. Several classes underwent refactoring, including the removal of methods related to casting in data type adapters, and the introduction of new error handling mechanisms. Additionally, many classes were moved to a new package structure, and documentation comments were added or updated for clarity. ## Changes | File Path | Change Summary | |--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `core/src/main/java-templates/gov/nist/secauto/metaschema/core/MetaschemaJavaVersion.java` | Field visibility changed from `public` to `private` for `NAME`, `VERSION`, `BUILD_TIMESTAMP`, `COMMIT`, `BRANCH`, `CLOSEST_TAG`, `ORIGIN`. Added class-level Javadoc comment. | | `core/src/main/java-templates/gov/nist/secauto/metaschema/core/model/MetaschemaVersion.java` | Field visibility changed from `public` to `private` for `NAME`, `BUILD_VERSION`, `BUILD_TIMESTAMP`, `COMMIT`, `BRANCH`, `CLOSEST_TAG`, `ORIGIN`. Updated `getVersion()` to return `BUILD_VERSION` instead of `CLOSEST_TAG`. Added class-level Javadoc comment. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/AbstractCustomJavaDataTypeAdapter.java` | Removed trailing newline; no functional changes. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/AbstractDataTypeAdapter.java` | Removed `cast` and `castInternal` methods; simplified casting logic. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/IDataTypeAdapter.java` | Removed `cast` method declaration. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/AbstractIntegerAdapter.java` | Enhanced error handling in `parse` and `writeJsonValue` methods. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/Base64Adapter.java` | Added class documentation. Updated `parse` and `asString` methods for null safety. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/BooleanAdapter.java` | Removed `castInternal` and associated methods; simplified control flow. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateAdapter.java` | Updated `DATE_TIMEZONE` initialization and enhanced error handling in `parse` and `asString` methods. Removed `castInternal`. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeAdapter.java` | Improved error handling and null safety in `parse` and `asString` methods. Removed `castInternal`. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeWithTZAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateWithTZAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DayTimeAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DecimalAdapter.java` | Changed `MATH_CONTEXT` visibility to private; removed constants and casting method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/EmailAddressAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/HostnameAdapter.java` | Updated method signature formatting; added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/IPv4AddressAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/IPv6AddressAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/IntegerAdapter.java` | Removed `castInternal` method; updated casting logic. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/MetaschemaDataTypeProvider.java` | Added multiple new static final fields for various data type adapters; updated constructor for registration. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/NcNameAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/NonNegativeIntegerAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/PositiveIntegerAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/StringAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/TokenAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/UriAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/UriReferenceAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/UuidAdapter.java` | Changed `UUID_PATTERN` visibility to private; added documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/YearMonthAdapter.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ComparisonFunctions.java` | Updated casting mechanism in `applyGeneralComparisonCast` method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/FunctionUtils.java` | Updated parameter type for `toNumeric` method; enhanced error handling in `requireType`. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCeiling.java` | Updated documentation comment to reflect correct function reference. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMinMax.java` | Added new imports and updated `normalize` method to use a new variable for primitive item types. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/AbstractAnyAtomicItem.java` | Changed inheritance to `AbstractAtomicItemBase`; removed abstract methods. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/AbstractAtomicItemBase.java` | Introduced new class for atomic item base implementation with methods for string representation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IAnyAtomicItem.java` | Updated `castAsType` method to include exception handling; removed `PRIMITIVE_ITEM_TYPES` constant. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IAnyUriItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IBase64BinaryItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IBooleanItem.java` | Updated `valueOf` and `cast` methods for improved error handling; added `castAsType` method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDateTimeItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDayTimeDurationItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDecimalItem.java` | Updated `valueOf` and `cast` methods for improved error handling; added `valueOf(boolean value)` method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IDurationItem.java` | Updated `cast` method for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IEmailAddressItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IHostnameItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIPAddressItem.java` | Added `cast` method for improved type casting. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIPv4AddressItem.java` | Added `valueOf` method for creating `IIPv4AddressItem` from string; updated `cast` method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIPv6AddressItem.java` | Added `valueOf` method for creating `IIPv6AddressItem` from string; updated `cast` method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIntegerItem.java` | Added `valueOf(boolean value)` method; updated `cast` method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IMarkupItem.java` | Added `valueOf` method for creating `IMarkupItem` from string; updated `cast` method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/INcNameItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/INonNegativeIntegerItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IPositiveIntegerItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IStringItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/ITemporalItem.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/ITokenItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IUntypedAtomicItem.java` | Added class-level documentation. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IUriReferenceItem.java` | Added `valueOf` method for creating `IUriReferenceItem` from string; updated `cast` method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IUuidItem.java` | Added `valueOf` method for creating `IUuidItem` from string; updated `cast` method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IYearMonthDurationItem.java` | Updated `valueOf` and `cast` methods for improved error handling. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractDateItem.java` | Implemented `IDateItem` interface; added `castAsType` method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractDateTimeItem.java` | Implemented `IDateTimeItem` interface; added `castAsType` method. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractDecimalItem.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractIntegerItem.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractStringItem.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractTemporalItem.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AbstractUriItem.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/AnyUriItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/Base64BinaryItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/BooleanItemImpl.java` | Updated package declaration; added documentation; constructor visibility changed to public. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateTimeWithTimeZoneItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateTimeWithoutTimeZoneItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateWithTimeZoneItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DateWithoutTimeZoneItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DayTimeDurationItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/DecimalItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/EmailAddressItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/HostnameItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/IPv4AddressItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/IPv6AddressItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/IntegerItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/MarkupLineItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/MarkupMultiLineItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/NcNameItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/NonNegativeIntegerItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/PositiveIntegerItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/StringItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/TokenItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/UriReferenceItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/UuidItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/impl/YearMonthDurationItemImpl.java` | Updated package declaration; added documentation; remains unchanged in functionality. | | `core/src/main/java/gov/nist/secauto/metaschema/core/model/validation/XmlSchemaContentValidator.java` | Updated exception handling in `toSchema` method to throw `IOException` instead of `SAXException`. | | `core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCeilingTest.java` | Updated test cases in `provideValues` method to use integer values instead of decimal values for certain arguments. | | `metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/CLITest.java` | Adjusted error message assertions in `testValidateContent` method for clarity. | | `schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGeneratorTestSuite.java` | Removed `SAXException` from catch block in `xmlContentValidatorProvider` method, simplifying error handling. |

🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
david-waltermire commented 2 days ago

@coderabbitai review

coderabbitai[bot] commented 2 days ago
:white_check_mark: Actions performed Review triggered. > Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.