-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add EchoRequester to java APIC-257 #90
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
Conversation
44849d9
to
69b06d2
Compare
* @throws ApiException If fail to serialize the request body object | ||
*/ | ||
public Call buildCall( | ||
public Object buildCall( |
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.
What if EchoRequester
returns something that extends Call
?
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.
Really good idea ! I tried it in 9631eaf
69b06d2
to
9631eaf
Compare
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.
Really nice!
clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java
Outdated
Show resolved
Hide resolved
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 really nice! Some minor questions
public String getPath() { | ||
return request.url().encodedPath(); | ||
} | ||
|
||
public String getMethod() { | ||
return request.method(); | ||
} | ||
|
||
public String getBody() { | ||
return parseRequestBody(request); | ||
} |
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.
Is it possible to have a default interface we can extend? So those methods are not duplicated in every classes
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.
or declare those and the request at the EchoResponse
class level 🤔
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.
Unfortunately Java classes can only extend from 1 class, and for the second point the parent class is not accessible from outside, the method would not be callable on the object itself and at the same time be a subclass of it's Response type.
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 EchoResponse
class acts as a namespace here, everything is static.
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.
There is the concept of default method for interface but an interface cannot have fields or constructor, so no access to the request
.
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.
and for the second point the parent class is not accessible from outside
I meant the utlity classes would be at the EchoResponse
level, and the method class would only override the request
value when called but yeah I don't know Java enough to explain my idea D:
Too bad it's not possible
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.
I get it but it's not possible to override at the same time the response (needed to have transparent type for the user) and the EchoResponse
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.
too bad
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.
Nice!!
🧭 What and Why
🎟 JIRA Ticket: APIC-257
Add the echo requester to the java client, it works by extending the normal response type and sending the echo response depending on the Requester.
The linter wasn't running properly before, this PR fixes all that.
Changes included:
🧪 Test
CI