/** * Create a new aggregating map expression using a backing TreeMap * * @param key key for the map entries * @param value value for the map entries * @return wrapper expression */ public static <K, V, T extends Comparable<? super T>, U> AbstractGroupExpression<Pair<K, V>, SortedMap<T, U>> sortedMap(GroupExpression<K, T> key, GroupExpression<V, U> value) { return new GMap.Mixin<K, V, T, U, SortedMap<T, U>>(key, value, GMap.createSorted(QPair.create(key, value))); }
@SuppressWarnings({ "rawtypes", "unchecked" }) public Mixin(GroupExpression<K, T> keyExpression, GroupExpression<V, U> valueExpression, AbstractGroupExpression<Pair<T, U>, R> mixin) { super((Class) mixin.getType(), QPair.create(keyExpression.getExpression(), valueExpression.getExpression())); this.keyExpression = keyExpression; this.valueExpression = valueExpression; this.mixin = mixin; }
/** * Create a new aggregating map expression using a backing LinkedHashMap * * @param key key for the map entries * @param value value for the map entries * @return wrapper expression */ public static <K, V, T, U> AbstractGroupExpression<Pair<K, V>, Map<T, U>> map(GroupExpression<K, T> key, GroupExpression<V, U> value) { return new GMap.Mixin<K, V, T, U, Map<T, U>>(key, value, GMap.createLinked(QPair.create(key, value))); }
/** * Create a new aggregating map expression using a backing TreeMap * * @param key key for the map entries * @param value value for the map entries * @return wrapper expression */ public static <K extends Comparable<? super K>, V, U> AbstractGroupExpression<Pair<K, V>, SortedMap<K, U>> sortedMap(Expression<K> key, GroupExpression<V, U> value) { return sortedMap(new GOne<K>(key), value); }
/** * Create a new aggregating map expression using a backing LinkedHashMap * * @param key key for the map entries * @param value value for the map entries * @return wrapper expression */ public static <K, V, T> AbstractGroupExpression<Pair<K, V>, Map<T, V>> map(GroupExpression<K, T> key, Expression<V> value) { return map(key, new GOne<V>(value)); }
@Override protected V transform(Group group) { return group.getOne(lookup); } };
/** * Create a new aggregating map expression using a backing TreeMap * * @param key key for the map entries * @param value value for the map entries * @return wrapper expression */ public static <K extends Comparable<? super K>, V> AbstractGroupExpression<Pair<K, V>, SortedMap<K, V>> sortedMap(Expression<K> key, Expression<V> value) { return GMap.createSorted(QPair.create(key, value)); }
/** * Create a new aggregating map expression using a backing LinkedHashMap * * @param key key for the map entries * @param value value for the map entries * @return wrapper expression */ public static <K, V> AbstractGroupExpression<Pair<K, V>,Map<K, V>> map(Expression<K> key, Expression<V> value) { return GMap.createLinked(QPair.create(key, value)); }
/** * Create a new aggregating set expression using a backing TreeSet using the given comparator * * @param groupExpression values for this expression will be accumulated into a set * @param comparator comparator of the created TreeSet instance * @return wrapper expression */ public static <E, F> GroupExpression<E, SortedSet<F>> sortedSet(GroupExpression<E, F> groupExpression, Comparator<? super F> comparator) { return new MixinGroupExpression<E, F, SortedSet<F>>(groupExpression, GSet.createSorted(groupExpression, comparator)); }
/** * Create a new aggregating set expression using a backing LinkedHashSet * * @param groupExpression values for this expression will be accumulated into a set * @param <E> * @param <F> * @return wrapper expression */ public static <E, F> GroupExpression<E, Set<F>> set(GroupExpression<E, F> groupExpression) { return new MixinGroupExpression<E, F, Set<F>>(groupExpression, GSet.createLinked(groupExpression)); }
/** * Create a new aggregating list expression * * @param groupExpression values for this expression will be accumulated into a list * @param <E> * @param <F> * @return wrapper expression */ public static <E, F> AbstractGroupExpression<E, List<F>> list(GroupExpression<E, F> groupExpression) { return new MixinGroupExpression<E, F, List<F>>(groupExpression, new GList<F>(groupExpression)); }
private <V> Expression<V> getLookup(Expression<V> expression) { if (expression instanceof GroupExpression) { @SuppressWarnings("unchecked") // This is the underlying type GroupExpression<V, ?> groupExpression = (GroupExpression<V, ?>) expression; return groupExpression.getExpression(); } else { return expression; } }
/** * Create a new aggregating map expression using a backing TreeMap * * @param key key for the map entries * @param value value for the map entries * @return wrapper expression */ public static <K, V, T extends Comparable<? super T>> AbstractGroupExpression<Pair<K, V>, SortedMap<T, V>> sortedMap(GroupExpression<K, T> key, Expression<V> value) { return sortedMap(key, new GOne<V>(value)); }
/** * Create a new aggregating map expression using a backing LinkedHashMap * * @param key key for the map entries * @param value value for the map entries * @return wrapper expression */ public static <K, V, U> AbstractGroupExpression<Pair<K, V>, Map<K, U>> map(Expression<K> key, GroupExpression<V, U> value) { return map(new GOne<K>(key), value); }
/** * Create a new aggregating map expression using a backing TreeMap using the given comparator * * @param key key for the map entries * @param value value for the map entries * @param comparator comparator for the created TreeMap instances * @return wrapper expression */ public static <K, V, T, U> AbstractGroupExpression<Pair<K, V>, SortedMap<T, U>> sortedMap(GroupExpression<K, T> key, GroupExpression<V, U> value, Comparator<? super T> comparator) { return new GMap.Mixin<K, V, T, U, SortedMap<T, U>>(key, value, GMap.createSorted(QPair.create(key, value), comparator)); }
/** * Create a new aggregating map expression using a backing TreeMap using the given comparator * * @param key key for the map entries * @param value value for the map entries * @param comparator comparator for the created TreeMap instances * @return wrapper expression */ public static <K, V> AbstractGroupExpression<Pair<K, V>, SortedMap<K, V>> sortedMap(Expression<K> key, Expression<V> value, Comparator<? super K> comparator) { return GMap.createSorted(QPair.create(key, value), comparator); }
/** * Create a new aggregating set expression using a backing TreeSet * * @param groupExpression values for this expression will be accumulated into a set * @return wrapper expression */ public static <E, F extends Comparable<? super F>> GroupExpression<E, SortedSet<F>> sortedSet(GroupExpression<E, F> groupExpression) { return new MixinGroupExpression<E, F, SortedSet<F>>(groupExpression, GSet.createSorted(groupExpression)); }
/** * Create a new aggregating map expression using a backing TreeMap using the given comparator * * @param key key for the map entries * @param value value for the map entries * @param comparator comparator for the created TreeMap instances * @return wrapper expression */ public static <K, V, T> AbstractGroupExpression<Pair<K, V>, SortedMap<T, V>> sortedMap(GroupExpression<K, T> key, Expression<V> value, Comparator<? super T> comparator) { return sortedMap(key, new GOne<V>(value), comparator); }
/** * Create a new aggregating map expression using a backing TreeMap using the given comparator * * @param key key for the map entries * @param value value for the map entries * @param comparator comparator for the created TreeMap instances * @return wrapper expression */ public static <K, V, U> AbstractGroupExpression<Pair<K, V>, SortedMap<K, U>> sortedMap(Expression<K> key, GroupExpression<V, U> value, Comparator<? super K> comparator) { return sortedMap(new GOne<K>(key), value, comparator); }