mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
Add getSorted* accessors
This commit is contained in:
parent
5446c9500a
commit
718fd2382e
@ -13,10 +13,7 @@
|
||||
*/
|
||||
package com.querydsl.core.group;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import com.querydsl.core.types.Expression;
|
||||
|
||||
@ -67,6 +64,17 @@ public interface Group {
|
||||
* @return Set of values in this group
|
||||
*/
|
||||
<T> Set<T> getSet(Expression<T> expr);
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of values in this group.
|
||||
*
|
||||
* @param <T> Value type of Set
|
||||
* @param expr Grouped expression
|
||||
* @throws NoSuchElementException if group is undefined.
|
||||
* @throws ClassCastException if group is of different type (e.g. List)
|
||||
* @return Set of values in this group
|
||||
*/
|
||||
<T> SortedSet<T> getSortedSet(Expression<T> expr);
|
||||
|
||||
/**
|
||||
* Returns a List of values in this group.
|
||||
@ -91,5 +99,18 @@ public interface Group {
|
||||
* @return Map of values in this group
|
||||
*/
|
||||
<K, V> Map<K, V> getMap(Expression<K> key, Expression<V> value);
|
||||
|
||||
/**
|
||||
* Returns a SortedMap of values in this group
|
||||
*
|
||||
* @param <K> Key type of result Map
|
||||
* @param <V> Value type of result Map
|
||||
* @param key Key expression
|
||||
* @param value Value expression
|
||||
* @throws NoSuchElementException if group is undefined.
|
||||
* @throws ClassCastException if group is of different type (e.g. List)
|
||||
* @return Map of values in this group
|
||||
*/
|
||||
<K, V> SortedMap<K, V> getSortedMap(Expression<K> key, Expression<V> value);
|
||||
|
||||
}
|
||||
@ -13,12 +13,7 @@
|
||||
*/
|
||||
package com.querydsl.core.group;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.Operation;
|
||||
@ -104,6 +99,16 @@ class GroupImpl implements Group {
|
||||
throw new NoSuchElementException("GMap(" + key + ", " + value + ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> SortedMap<K, V> getSortedMap(Expression<K> key, Expression<V> value) {
|
||||
for (QPair<?, ?> pair : maps) {
|
||||
if (pair.equals(key, value)) {
|
||||
return (SortedMap<K, V>) groupCollectorMap.get(pair).get();
|
||||
}
|
||||
}
|
||||
throw new NoSuchElementException("GMap(" + key + ", " + value + ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getOne(Expression<T> expr) {
|
||||
return this.<T, T>get(expr);
|
||||
@ -114,6 +119,11 @@ class GroupImpl implements Group {
|
||||
return this.<T, Set<T>>get(expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> SortedSet<T> getSortedSet(Expression<T> expr) {
|
||||
return this.<T, SortedSet<T>>get(expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
List<Object> arr = new ArrayList<Object>(groupCollectors.size());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user