mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
organized imports, use type check in CollectionUtils
This commit is contained in:
parent
c9eafe35f4
commit
00464a92fb
@ -35,7 +35,7 @@ public final class JoinExpression implements Serializable {
|
||||
@Nullable
|
||||
private final Predicate condition;
|
||||
|
||||
private final Set<JoinFlag> flags;
|
||||
private final ImmutableSet<JoinFlag> flags;
|
||||
|
||||
private final Expression<?> target;
|
||||
|
||||
@ -65,7 +65,7 @@ public final class JoinExpression implements Serializable {
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
this.condition = condition;
|
||||
this.flags = flags;
|
||||
this.flags = ImmutableSet.copyOf(flags);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@ -26,9 +26,10 @@ import com.google.common.collect.ImmutableList;
|
||||
*/
|
||||
public final class SearchResults<T> {
|
||||
|
||||
private static final SearchResults EMPTY = new SearchResults(
|
||||
private static final SearchResults<Object> EMPTY = new SearchResults<Object>(
|
||||
ImmutableList.of(), Long.MAX_VALUE, 0l, 0l);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> SearchResults<T> emptyResults() {
|
||||
return (SearchResults<T>)EMPTY;
|
||||
};
|
||||
|
||||
@ -49,6 +49,7 @@ public interface SimpleProjectable<T> {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
CloseableIterator<T> iterateDistinct();
|
||||
|
||||
/**
|
||||
@ -63,6 +64,7 @@ public interface SimpleProjectable<T> {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
List<T> listDistinct();
|
||||
|
||||
/**
|
||||
@ -96,6 +98,7 @@ public interface SimpleProjectable<T> {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
SearchResults<T> listDistinctResults();
|
||||
|
||||
/**
|
||||
@ -110,6 +113,7 @@ public interface SimpleProjectable<T> {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
long countDistinct();
|
||||
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ public abstract class SerializerBase<S extends SerializerBase<S>> implements Vis
|
||||
|
||||
private String anonParamPrefix = "_";
|
||||
|
||||
private final Map<Object,String> constantToLabel = new HashMap<Object,String>(4);
|
||||
private Map<Object,String> constantToLabel;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private final S self = (S) this;
|
||||
@ -82,6 +82,9 @@ public abstract class SerializerBase<S extends SerializerBase<S>> implements Vis
|
||||
}
|
||||
|
||||
public Map<Object,String> getConstantToLabel() {
|
||||
if (constantToLabel == null) {
|
||||
constantToLabel = new HashMap<Object,String>(4);
|
||||
}
|
||||
return constantToLabel;
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ public final class OperatorImpl<T> implements Operator<T> {
|
||||
}
|
||||
|
||||
public OperatorImpl(String id, ImmutableList<Class<?>> types) {
|
||||
this.id = id.intern();
|
||||
this.id = id;
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
@ -52,8 +52,7 @@ public final class OperatorImpl<T> implements Operator<T> {
|
||||
if (o == this) {
|
||||
return true;
|
||||
} else if (o instanceof Operator<?>) {
|
||||
// Strings are interned, so this is safe
|
||||
return ((Operator<?>)o).getId() == id;
|
||||
return ((Operator<?>)o).getId().equals(id);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -70,8 +70,6 @@ public enum PathType implements Operator<Path<?>> {
|
||||
*/
|
||||
VARIABLE;
|
||||
|
||||
private final String id = name().intern();
|
||||
|
||||
@Override
|
||||
public List<Class<?>> getTypes() {
|
||||
return Collections.emptyList();
|
||||
@ -79,7 +77,7 @@ public enum PathType implements Operator<Path<?>> {
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
return name();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -120,8 +120,8 @@ public class QTuple extends ExpressionBase<Tuple> implements FactoryExpression<T
|
||||
public QTuple(Expression<?>[]... args) {
|
||||
super(Tuple.class);
|
||||
ImmutableList.Builder<Expression<?>> builder = ImmutableList.builder();
|
||||
for (Expression<?>[] exprs: args){
|
||||
builder.addAll(Arrays.asList(exprs));
|
||||
for (Expression<?>[] exprs: args) {
|
||||
builder.add(exprs);
|
||||
}
|
||||
this.args = builder.build();
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.mysema.query.types;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -27,9 +27,9 @@ public class Templates {
|
||||
|
||||
public static final Templates DEFAULT = new Templates();
|
||||
|
||||
private final Map<String, Template> templates = new IdentityHashMap<String, Template>();
|
||||
private final Map<String, Template> templates = new HashMap<String, Template>();
|
||||
|
||||
private final Map<String, Integer> precedence = new IdentityHashMap<String, Integer>();
|
||||
private final Map<String, Integer> precedence = new HashMap<String, Integer>();
|
||||
|
||||
private final TemplateFactory templateFactory;
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ public final class CollectionUtils {
|
||||
public static <T> List<T> add(List<T> list, T element) {
|
||||
if (list.isEmpty()) {
|
||||
return ImmutableList.of(element);
|
||||
} else if (list.size() == 1) {
|
||||
} else if (list instanceof ImmutableList) {
|
||||
final List<T> old = list;
|
||||
list = Lists.newArrayList();
|
||||
list.add(old.get(0));
|
||||
@ -48,7 +48,7 @@ public final class CollectionUtils {
|
||||
public static <T> Set<T> add(Set<T> set, T element) {
|
||||
if (set.isEmpty()) {
|
||||
return ImmutableSet.of(element);
|
||||
} else if (set.size() == 1) {
|
||||
} else if (set instanceof ImmutableSet) {
|
||||
final Set<T> old = set;
|
||||
set = Sets.newHashSet();
|
||||
set.add(old.iterator().next());
|
||||
@ -60,7 +60,7 @@ public final class CollectionUtils {
|
||||
public static <T> Set<T> addSorted(Set<T> set, T element) {
|
||||
if (set.isEmpty()) {
|
||||
return ImmutableSet.of(element);
|
||||
} else if (set.size() == 1) {
|
||||
} else if (set instanceof ImmutableSet) {
|
||||
Set<T> old = set;
|
||||
set = Sets.newLinkedHashSet();
|
||||
set.add(old.iterator().next());
|
||||
@ -72,7 +72,7 @@ public final class CollectionUtils {
|
||||
public static <K,V> Map<K,V> put(Map<K,V> map, K key, V value) {
|
||||
if (map.isEmpty()) {
|
||||
return ImmutableMap.of(key, value);
|
||||
} else if (map.size() == 1) {
|
||||
} else if (map instanceof ImmutableMap) {
|
||||
map = Maps.newHashMap(map);
|
||||
}
|
||||
map.put(key, value);
|
||||
|
||||
@ -13,8 +13,6 @@
|
||||
*/
|
||||
package com.mysema.query.jpa;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.mysema.query.DefaultQueryMetadata;
|
||||
import com.mysema.query.JoinExpression;
|
||||
import com.mysema.query.JoinType;
|
||||
|
||||
@ -13,8 +13,6 @@
|
||||
*/
|
||||
package com.mysema.query.jpa;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.mysema.query.Query;
|
||||
import com.mysema.query.types.CollectionExpression;
|
||||
import com.mysema.query.types.EntityPath;
|
||||
|
||||
@ -28,7 +28,6 @@ import com.mysema.query.types.ExpressionUtils;
|
||||
import com.mysema.query.types.Path;
|
||||
import com.mysema.query.types.Predicate;
|
||||
import com.mysema.query.types.TemplateExpressionImpl;
|
||||
import com.mysema.query.types.path.ListPath;
|
||||
|
||||
/**
|
||||
* JPAQueryMixin extends {@link QueryMixin} to support JPQL join construction
|
||||
|
||||
Loading…
Reference in New Issue
Block a user