mercredi 29 mars 2017

How to form a single API from these methods?

I have an interface with the following methods:

public ArrayList<ArrayList<Pair<Integer, Integer>>> getDataFormated(SomeEnum type);  


public ArrayList<ArrayList<Pair<Integer, String>>> getDataForInfo();  

The first method based on the type populates the return result correctly.
Both method are using the same data (which is basically a json file) to do their processing.

How would I make them into 1 method?
I could make the return result from the first method as ArrayList<ArrayList<Pair<Integer, String>>> since the integer can be converted back and forth to string as needed but seems to me error prone.
What would be an alternative? How could I use templates here or some other way?

Aucun commentaire:

Enregistrer un commentaire