-
Notifications
You must be signed in to change notification settings - Fork 19
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
gh-175 Adds schema class exists method #196
Conversation
To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge. |
private String className; | ||
|
||
public ClassExists(HttpClient httpClient, Config config) { | ||
this.classGetter = new ClassGetter(httpClient, config); |
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.
Avoid creating instances of dependencies inside classes. Instead create dependencies outside and inject them as arguments of constructor.
It will make testing a lot easier by using mocks instead of real implementations.
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.
prefix is not necessary here
src/main/java/io/weaviate/client/v1/schema/api/ClassExists.java
Outdated
Show resolved
Hide resolved
WeaviateErrorMessage errorMessage = WeaviateErrorMessage.builder() | ||
.message("classname cannot be empty").build(); | ||
WeaviateErrorResponse errors = WeaviateErrorResponse.builder() | ||
.error(Stream.of(errorMessage).collect(Collectors.toList())).build(); |
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.
Stream.of(errorMessage).collect(Collectors.toList())
although correct, stream seems to be a bit excessive here.
Arrays.asList(errorMessage)
or Collections.singletonList(errorMessage)
can be used instead.
src/main/java/io/weaviate/client/v1/schema/api/ClassExists.java
Outdated
Show resolved
Hide resolved
src/main/java/io/weaviate/client/v1/schema/api/ClassExists.java
Outdated
Show resolved
Hide resolved
Addressed the review comments in latest commit |
return this; | ||
} | ||
|
||
private Result<Boolean> toResult(WeaviateError error) { |
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.
not used at the moment
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.
missed it, removed now
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!
Addresses #175
client.schema().exists().withClassName("clazz").run(); //returns Result<Boolean>