A Generic method to convert ResultSetFuture (of Datastax Java driver for Cassandra) to a list of table-row-model(POJO) for any table query
This post shows my new found love for CompletableFuture , lamdba expression and Streams API in Java. Problem: You do an async query on a table, get a ResultSetFuture object and need to populate a list of java objects representing a row in Cassandra table. A normal way to do this would be Assume: ResultSetFuture rsf = resultFromSomeTableQuery(); ResultSet rs = rsf.get(); //get ResultSet from rsf get all rows as list by rs.all() now for each Row in above list create a new object(POJO/java object representing table row) and populate the new object by calling Row.get(column index) for each column. This would lead to writing new code which does same task of converting ResultSetFuture to List of POJOs for each table query. Solution: I'll give my solution approach with an example