Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate KnowledgeIndex reflection #541

Merged
merged 1 commit into from
Aug 26, 2020

Conversation

mtdowling
Copy link
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