gchq / MagmaCore

Magma Core is a collection of Java Classes and utilities to enable HQDM objects and patterns to be created and consumed as RDF Linked Data.
Apache License 2.0
26 stars 4 forks source link

Improve Type Checking #197

Closed twalmsley closed 7 months ago

twalmsley commented 8 months ago

This PR relates to issue 185 but shouldn't be used to close that issue, it should remain open, because this PR doesn't address any of the main issues in my latest comment on that issue.

This PR updates the model-extension-example to include a ParentChildAssociation entity type along with Person and Child types, as well as an example in the examples module called ParentChildAssociationFunction showing how to create the association in a type-safe way.

The ParentChildAssociationFunction is designed for use with MagmaCoreService.runInWriteTransaction(), but also, since it is a Function it can be composed together with other Functions to produce larger blocks of code that can be executed in single transactions if desired. (My other project calls this kind of Function an Executor).

This Function (aka Executor) pattern is a useful way to package up useful functionality into re-usable blocks that build parts of a High Quality Data Model (HQDM) in as type-safe a way as is possible with the current state of MagmaCore.