[#1708] Add <T, E> Map<T, List<E>> ResultQuery.fetchGroupsInto(Field<T>,
Class<E>) - Renamed "fetchIntoGroups" to "fetchGroups" - Replaced usage of LinkedList by ArrayList
This commit is contained in:
parent
a79783aa41
commit
921056dba0
@ -537,6 +537,22 @@ public interface ResultQuery<R extends Record> extends Query {
|
||||
*/
|
||||
<K, V> Map<K, List<V>> fetchGroups(Field<K> key, Field<V> value) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Return a {@link Map} with results grouped by the given key and mapped
|
||||
* into the given entity type.
|
||||
*
|
||||
* @param <K> The key's generic field type
|
||||
* @param <E> The generic entity type.
|
||||
* @param key The key field.
|
||||
* @param type The entity type.
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @throws MappingException wrapping any reflection or data type conversion
|
||||
* exception that might have occurred while mapping records
|
||||
* @see Result#intoGroups(Field, Class)
|
||||
*/
|
||||
<K, E> Map<K, List<E>> fetchGroups(Field<K> key, Class<? extends E> type) throws DataAccessException,
|
||||
MappingException;
|
||||
|
||||
/**
|
||||
* Execute the query and return the generated result as an Object matrix
|
||||
* <p>
|
||||
@ -730,22 +746,6 @@ public interface ResultQuery<R extends Record> extends Query {
|
||||
*/
|
||||
<H extends RecordHandler<R>> H fetchInto(H handler) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Return a {@link Map} with results grouped by the given key and mapped
|
||||
* into the given entity type.
|
||||
*
|
||||
* @param <K> The key's generic field type
|
||||
* @param <E> The generic entity type.
|
||||
* @param key The key field.
|
||||
* @param type The entity type.
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @throws MappingException wrapping any reflection or data type conversion
|
||||
* exception that might have occurred while mapping records
|
||||
* @see Result#intoGroups(Field, Class)
|
||||
*/
|
||||
<K, E> Map<K, List<E>> fetchIntoGroups(Field<K> key, Class<? extends E> type) throws DataAccessException,
|
||||
MappingException;
|
||||
|
||||
/**
|
||||
* Fetch results asynchronously.
|
||||
* <p>
|
||||
|
||||
@ -324,8 +324,8 @@ abstract class AbstractDelegatingSelect<R extends Record>
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <K, E> Map<K, List<E>> fetchIntoGroups(Field<K> key, Class<? extends E> type) {
|
||||
return getDelegate().fetchIntoGroups(key, type);
|
||||
public final <K, E> Map<K, List<E>> fetchGroups(Field<K> key, Class<? extends E> type) {
|
||||
return getDelegate().fetchGroups(key, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -517,7 +517,7 @@ abstract class AbstractResultQuery<R extends Record> extends AbstractQuery imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <K, E> Map<K, List<E>> fetchIntoGroups(Field<K> key, Class<? extends E> type) {
|
||||
public final <K, E> Map<K, List<E>> fetchGroups(Field<K> key, Class<? extends E> type) {
|
||||
return fetch().intoGroups(key, type);
|
||||
}
|
||||
|
||||
|
||||
@ -57,7 +57,6 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
@ -1449,7 +1448,7 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
|
||||
List<E> list = map.get(keyVal);
|
||||
if (list == null) {
|
||||
list = new LinkedList<E>();
|
||||
list = new ArrayList<E>();
|
||||
map.put(keyVal, list);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user