package eu.dnetlib.data.collective.transformation.engine; import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; /** * @author js * */ public class FunctionResults { private Map> resultMap = new LinkedHashMap>(); /** * get the first single result from the result list at the given index * @param aIndex * @return a result */ public String get(int aIndex){ return resultMap.get(aIndex + "").get(0); } /** * get the single result for the node at the given position from the list at the given index * @param aIndex * @param aPosition * @return a result */ public String get(int aIndex, int aPosition){ if (aPosition <= 0){ throw new IllegalArgumentException("position is " + aPosition + ", must be greater 0"); } return resultMap.get(aIndex + "").get(aPosition - 1); } /** * add a collection containing the results for each record * @param aCollection */ public void addAll(Collection aCollection){ for (String result : aCollection){ add(result); } } /** * add a single result calculated for a record node * @param aResult */ public void add(String aResult){ List resultList = new LinkedList(); resultList.add(aResult); resultMap.put(resultMap.size() + "", resultList); } /** * add a list of results calculated for all resp. record nodes * @param aResults */ public void add(List aResults){ resultMap.put(resultMap.size() + "", aResults); } }