Skip to content

Deprecate KnowledgeIndex reflection#541

Merged
mtdowling merged 1 commit intomasterfrom
remove-knowledge-index-reflection
Aug 26, 2020
Merged

Deprecate KnowledgeIndex reflection#541
mtdowling merged 1 commit intomasterfrom
remove-knowledge-index-reflection

Conversation

@mtdowling
Copy link
Copy Markdown
Member

This commit deprecates the old access pattern used to create a
KnowledgeIndex (model.getKnowledge(X.class)) in favor of using a new
convention: X.of(model). KnowledgeIndex implementations are now
expected to provide a public static method named of that accepts a
Model and returns an instance of the class. The instance should be
created by calling model.getKnowledge(Class<T>, Function<Model, T>)
which will ensure the index is cached in the given model.

This change is the first step towards seeing if we can get full GraalVM
native image support. It also makes using a KnowledgeIndex more
ergonomic IMO, and remove reflection, which is generally a good thing.

The deprecated method will eventually be removed in a subsequent
release.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This commit deprecates the old access pattern used to create a
KnowledgeIndex (`model.getKnowledge(X.class)`) in favor of using a new
convention: `X.of(model)`. KnowledgeIndex implementations are now
expected to provide a public static method named `of` that accepts a
`Model` and returns an instance of the class. The instance should be
created by calling `model.getKnowledge(Class<T>, Function<Model, T>)`
which will ensure the index is cached in the given model.

This change is the first step towards seeing if we can get full GraalVM
native image support. It also makes using a KnowledgeIndex more
ergonomic IMO, and remove reflection, which is generally a good thing.

The deprecated method will eventually be removed in a subsequent
release.
@mtdowling mtdowling requested a review from kstich August 25, 2020 19:56
@mtdowling mtdowling merged commit ec1af60 into master Aug 26, 2020
@mtdowling mtdowling deleted the remove-knowledge-index-reflection branch September 14, 2020 22:49
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.

2 participants