mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
add overload of recordsToMap that takes key type
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
Reference in New Issue
Block a user