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

Thing.addValue() is not tight enough #191

Closed twalmsley closed 9 months ago

twalmsley commented 9 months ago

A very common mistake in code with MagmaCore is to forget to call getId() on a Thing when it is the target of a predicate. E.g.:

    thing.addValue(HQDM.PART_OF_POSSIBLE_WORLD, possibleWorld);

when the third argument should be possibleWorld.getId() because the target needs to be an IRI.

I propose to overload the addValue() method with more type-specific versions that will prevent this error.

Relates to #185