Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2015, The Querydsl Team (http://www.querydsl.com/team)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mysema.query.group;
import java.util.*;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import com.mysema.commons.lang.Pair;
import com.mysema.query.types.Expression;
import com.mysema.query.types.QList;
/**
* Groups results by the first expression.
*
* @author sasa
* @author tiwe
*
*/
public final class GroupBy {
/**
* Create a new GroupByBuilder for the given key expression
*
* @param key
* @return
*/
public static GroupByBuilder groupBy(Expression key) {
return new GroupByBuilder(key);
}
/**
* Create a new GroupByBuilder for the given key expressions
*
* @param keys
* @return
*/
public static GroupByBuilder> groupBy(Expression>... keys) {
return new GroupByBuilder>(new QList(keys));
}
/**
* Create a new aggregating min expression
*
* @param expression
* @return
*/
public static > AbstractGroupExpression min(Expression expression) {
return new GMin(expression);
}
/**
* Create a new aggregating sum expression
*
* @param expression
* @return
*/
public static AbstractGroupExpression sum(Expression expression) {
return new GSum(expression);
}
/**
* Create a new aggregating avg expression
*
* @param expression
* @return
*/
public static AbstractGroupExpression avg(Expression expression) {
return new GAvg(expression);
}
/**
* Create a new aggregating max expression
*
* @param expression
* @return
*/
public static > AbstractGroupExpression max(Expression expression) {
return new GMax(expression);
}
/**
* Create a new aggregating list expression
*
* @param expression
* @return
*/
public static AbstractGroupExpression> list(Expression expression) {
return new GList(expression);
}
public static AbstractGroupExpression> list(GroupExpression groupExpression) {
return new MixinGroupExpression>(groupExpression, new GList(groupExpression));
}
/**
* Create a new aggregating set expression using a backing LinkedHashSet
*
* @param expression
* @return
*/
public static AbstractGroupExpression> set(Expression expression) {
return GSet.createLinked(expression);
}
public static GroupExpression> set(GroupExpression groupExpression) {
return new MixinGroupExpression>(groupExpression, GSet.createLinked(groupExpression));
}
/**
* Create a new aggregating set expression using a backing TreeSet
*
* @param expression
* @return
*/
public static > AbstractGroupExpression> sortedSet(Expression expression) {
return GSet.createSorted(expression);
}
/**
* Create a new aggregating set expression using a backing TreeSet
*
* @param groupExpression
* @return
*/
public static > GroupExpression> sortedSet(GroupExpression groupExpression) {
return new MixinGroupExpression>(groupExpression, GSet.createSorted(groupExpression));
}
/**
* Create a new aggregating set expression using a backing TreeSet using the given comparator
*
* @param expression
* @param comparator
* @return
*/
public static AbstractGroupExpression> sortedSet(Expression expression, Comparator super E> comparator) {
return GSet.createSorted(expression, comparator);
}
/**
* Create a new aggregating set expression using a backing TreeSet using the given comparator
*
* @param groupExpression
* @param comparator
* @return
*/
public static GroupExpression> sortedSet(GroupExpression groupExpression, Comparator super F> comparator) {
return new MixinGroupExpression>(groupExpression, GSet.createSorted(groupExpression, comparator));
}
/**
* Create a new aggregating map expression using a backing LinkedHashMap
*
* @param key
* @param value
* @return
*/
@WithBridgeMethods(value=Expression.class,castRequired=true)
public static AbstractGroupExpression,Map> map(Expression key, Expression value) {
return GMap.createLinked(QPair.create(key, value));
}
/**
* Create a new aggregating map expression using a backing LinkedHashMap
*
* @param key
* @param value
* @return
*/
public static AbstractGroupExpression, Map> map(GroupExpression key, Expression value) {
return map(key, new GOne(value));
}
/**
* Create a new aggregating map expression using a backing LinkedHashMap
*
* @param key
* @param value
* @return
*/
public static AbstractGroupExpression, Map> map(Expression key, GroupExpression value) {
return map(new GOne(key), value);
}
/**
* Create a new aggregating map expression using a backing LinkedHashMap
*
* @param key
* @param value
* @return
*/
public static AbstractGroupExpression, Map> map(GroupExpression key, GroupExpression value) {
return new GMap.Mixin>(key, value, GMap.createLinked(QPair.create(key, value)));
}
/**
* Create a new aggregating map expression using a backing TreeMap
*
* @param key
* @param value
* @return
*/
public static , V> AbstractGroupExpression, SortedMap> sortedMap(Expression key, Expression value) {
return GMap.createSorted(QPair.create(key, value));
}
/**
* Create a new aggregating map expression using a backing TreeMap
*
* @param key
* @param value
* @return
*/
public static , V, T extends Comparable super T>> AbstractGroupExpression, SortedMap> sortedMap(GroupExpression key, Expression value) {
return sortedMap(key, new GOne(value));
}
/**
* Create a new aggregating map expression using a backing TreeMap
*
* @param key
* @param value
* @return
*/
public static , V, U> AbstractGroupExpression, SortedMap> sortedMap(Expression key, GroupExpression value) {
return sortedMap(new GOne(key), value);
}
/**
* Create a new aggregating map expression using a backing TreeMap
*
* @param key
* @param value
* @return
*/
public static , V, T extends Comparable super T>, U> AbstractGroupExpression, SortedMap> sortedMap(GroupExpression key, GroupExpression value) {
return new GMap.Mixin>(key, value, GMap.createSorted(QPair.create(key, value)));
}
/**
* Create a new aggregating map expression using a backing TreeMap using the given comparator
*
* @param key
* @param value
* @param comparator
* @return
*/
public static AbstractGroupExpression, SortedMap> sortedMap(Expression key, Expression value, Comparator super K> comparator) {
return GMap.createSorted(QPair.create(key, value), comparator);
}
/**
* Create a new aggregating map expression using a backing TreeMap using the given comparator
*
* @param key
* @param value
* @param comparator
* @return
*/
public static AbstractGroupExpression, SortedMap> sortedMap(GroupExpression key, Expression value, Comparator super K> comparator) {
return sortedMap(key, new GOne(value), comparator);
}
/**
* Create a new aggregating map expression using a backing TreeMap using the given comparator
*
* @param key
* @param value
* @param comparator
* @return
*/
public static AbstractGroupExpression, SortedMap> sortedMap(Expression key, GroupExpression value, Comparator super U> comparator) {
return sortedMap(new GOne(key), value, comparator);
}
/**
* Create a new aggregating map expression using a backing TreeMap using the given comparator
*
* @param key
* @param value
* @param comparator
* @return
*/
public static AbstractGroupExpression, SortedMap> sortedMap(GroupExpression key, GroupExpression value, Comparator super T> comparator) {
return new GMap.Mixin>(key, value, GMap.createSorted(QPair.create(key, value), comparator));
}
private GroupBy() {}
}