jwbf
jwbf copied to clipboard
How to do custom queries
I searching a way to do custom queries. For example I want to the get the equivalent article in the English Wikipedia for a French Wikipedia article. Is there something like this:
Get query = buildQuerie(); result = getAPIResponse(query) ;
The result could be a String (the raw response of the API), a HashMap created from the JSON response of the API. Or we could pass a class to get the result in custom object that will be created from the JSON response (we will use Jackson library here).
What do you think?
Sounds good, a new continuation query was implemented this way a few days ago in #18 by gerhardgossen.
Try following shortcuts
Thats's what I'm searching for but my idea is to make write a costume class let's say Query, and have this functions:
String getRawResponse() it return the raw response of the server HashMap<Object,Object> getResponseAsHashMap() that return a hashmap created from the json response T <T> getResponse(Class<T> clazz) that return an object of the type of that class that will be created from the json response.
The advantage of this is that we will let users to build their request and the results. Now when we want to do a request we must create a new class (like did gerhardgossen).
Sounds interesting, feel free to send a pull request, maybe with a test that shows the benefits of your idea.
What is the disadvantage of writing a new class (except for javas garrulity)?