I would like to have something like this in Java :
import java.util.List;
class Query<T> {
public List<T> fetch() {
// Get the table name, T.tableName()
// Fetch from /api/<table_name>
// Parse and return data, T.parseJSON(jsonData)
}
}
The intention here is to have a generic query builder, while each class T defines its specific tableName and parseJSON functions. For example,
class Article {
public static String tableName() {
return "article";
}
public static List<Article> parseJSON(String jsonData) {
// Parse the json, build the articles
}
}
How do I write the fetch function in the Query class?
Articleobject to use them.