-
Notifications
You must be signed in to change notification settings - Fork 10
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
AnswerSetQuery: API feature to query answer sets in a fluent way #287
Conversation
I have a few general questions first:
|
Currently the idea is to only match single predicates per query. I thought about doing more than one and then have what you suggest, but then
Do you mean just adding an additional filter method such as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, aside from some minor suggestions.
src/main/java/at/ac/tuwien/kr/alpha/api/query/AnswerSetQuery.java
Outdated
Show resolved
Hide resolved
src/main/java/at/ac/tuwien/kr/alpha/api/query/AnswerSetQuery.java
Outdated
Show resolved
Hide resolved
* @param termIdx | ||
* @param str | ||
* @return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A general thought on this: our IDEs create these javadoc parameter descriptions automatically, but as long as we do not fill them in, we might as well delete the javadoc parameters.
* @return | ||
*/ | ||
public AnswerSetQuery withConstantEquals(int termIdx, String str) { | ||
return this.withFilter(termIdx, AnswerSetQuery.constantTermEquals(str)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method constantTermEquals
is only used here and can be inlined as follows:
return this.withFilter(termIdx, AnswerSetQuery.constantTermEquals(str)); | |
return this.withFilter(termIdx, (t) -> AnswerSetQuery.constantTermEquals(t, str)); |
private static java.util.function.Predicate<Term> constantTermEquals(final String str) { | ||
java.util.function.Predicate<Term> equalsGivenString = (t) -> { | ||
return AnswerSetQuery.constantTermEquals(t, str); | ||
}; | ||
return equalsGivenString; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can be deleted if the above suggestion to inline it is accepted.
Co-authored-by: Antonius Weinzierl <AntoniusW@users.noreply.github.com>
Co-authored-by: Antonius Weinzierl <AntoniusW@users.noreply.github.com>
This PR adds a new class
AnswerSetQuery
that allows API users to process answer sets with a bit less boilerplate code.Usage
Answer set queries can be used via the new
AnswerSet#query
method that accepts anAnswerSetQuery
as its argument.For an intuition on how to use answer set queries, see below examples: