QuotedIDFactory refactoring introducing type annotation and lookup by type #644
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a mechanism to link a
QuotedIDFactory
to a factory type string viaQuotedIDFactory.@IDFactoryType
annotations, and to lookup aQuotedIDFactory
instance via aQuotedIDFactory.Supplier
interface obtainable via injection.QuotedIDFactory.Supplier
injection leverages the a refactoring ofOntopAbstractModule
that now allows the binding (overridable in settings file) of an implementation class to an arbitrary Guice <class, qualifier> key (instead of an abstract class key only), where the qualifier denotes here the factory type and allows having multiple coexistingQuotedIDFactory
bindings for different type qualifiers. Specifically,QuotedIDFactory
implementation classes are bound inOntopSQLCoreModule
while an implementation ofQuotedIDFactory.Supplier
delegating to GuiceInjector
is bound inOntopModelModule
.Note that the extension of
OntopAbstractModule
is general and can be used for similar use cases. Two unit tests are provided inOntopAbstractModuleTest
andQuotedIDFactoryInjectionTest
, respectively for the handling of generic <class, qualifier> keys and its use forQuotedIDFactory.Supplier
.A
QuotedIDFactory.Supplier
is now injected intoJsonMetadata
when deserializing from JSON (via Jackson injection fromJsonSerializedMetadataProvider
). This allows obtaining aQuotedIDFactory
instance for the factory type occurring in the JSON by ultimately delegating to Guice (where knowledge about object instantiation resides), instead of hard-coding a <type, implementation class>BiMap
and directly usingClass.newInstance()
.Other changes in the PR are related to minor cleanup of other involved files (e.g., simplified binding expression in
OntopReformulationPostModule
, nullability handling inQuotedIDImpl
) and in the use of a@NonNullByDefault
annotation (taken from io.github.solf:nullanno just not to define it in Ontop code) to simplify and improve consistency - and thus improve IDE nullability analysis - of null-related annotations: when used on a class/package (as in classes modified in the PR), everything has to be non-null except where otherwise specified with@Nullable
.