add overload of recordsToMap that takes key type

This commit is contained in:
2024-03-19 19:59:34 -05:00
parent 5963a706b0
commit 605578d661

View File

@ -518,6 +518,24 @@ public class CollectionUtils
/*******************************************************************************
** Convert a collection of QRecords to a map, from one field's values out of
** those records, to the records themselves.
*******************************************************************************/
public static <T extends Serializable> Map<T, QRecord> recordsToMap(Collection<QRecord> records, String keyFieldName, Class<T> type)
{
Map<T, QRecord> rs = new HashMap<>();
for(QRecord record : nonNullCollection(records))
{
rs.put(ValueUtils.getValueAsType(type, record.getValue(keyFieldName)), record);
}
return (rs);
}
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/