jwbf icon indicating copy to clipboard operation
jwbf copied to clipboard

How to do custom queries

Open Hunsu opened this issue 10 years ago • 3 comments

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?

Hunsu avatar Dec 08 '14 13:12 Hunsu

Sounds good, a new continuation query was implemented this way a few days ago in #18 by gerhardgossen.

Try following shortcuts

eldur avatar Dec 08 '14 22:12 eldur

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).

Hunsu avatar Dec 30 '14 12:12 Hunsu

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)?

eldur avatar Jan 01 '15 20:01 eldur