added Immutable annotation

This commit is contained in:
Timo Westkämper 2012-12-16 17:26:16 +02:00
parent 00464a92fb
commit 7e19a40f52
20 changed files with 56 additions and 11 deletions

View File

@ -17,6 +17,7 @@ import java.io.Serializable;
import java.util.Set;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
@ -28,6 +29,7 @@ import com.mysema.query.types.Predicate;
*
* @author tiwe
*/
@Immutable
public final class JoinExpression implements Serializable {
private static final long serialVersionUID = -1131755765747174886L;

View File

@ -15,6 +15,8 @@ package com.mysema.query;
import java.io.Serializable;
import javax.annotation.concurrent.Immutable;
import com.mysema.query.types.Expression;
import com.mysema.query.types.TemplateExpressionImpl;
@ -24,6 +26,7 @@ import com.mysema.query.types.TemplateExpressionImpl;
* @author tiwe
*
*/
@Immutable
public class JoinFlag implements Serializable{
public enum Position {

View File

@ -19,11 +19,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.Immutable;
/**
* ConstantImpl is the default implementation of the Constant interface
*
* @author tiwe
*/
@Immutable
@SuppressWarnings("unchecked")
public final class ConstantImpl<T> extends ExpressionBase<T> implements Constant<T> {

View File

@ -20,6 +20,7 @@ import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Primitives;
@ -42,6 +43,7 @@ import com.google.common.primitives.Primitives;
*
* @param <T> expression type
*/
@Immutable
public class ConstructorExpression<T> extends ExpressionBase<T> implements FactoryExpression<T> {
private static final long serialVersionUID = -602747921848073175L;
@ -79,7 +81,7 @@ public class ConstructorExpression<T> extends ExpressionBase<T> implements Facto
return new ConstructorExpression<D>(type, paramTypes, args);
}
private final List<Expression<?>> args;
private final ImmutableList<Expression<?>> args;
private final Class<?>[] parameterTypes;
@ -90,7 +92,7 @@ public class ConstructorExpression<T> extends ExpressionBase<T> implements Facto
this(type, paramTypes, ImmutableList.copyOf(args));
}
public ConstructorExpression(Class<T> type, Class<?>[] paramTypes, List<Expression<?>> args) {
public ConstructorExpression(Class<T> type, Class<?>[] paramTypes, ImmutableList<Expression<?>> args) {
super(type);
this.parameterTypes = getRealParameters(type, paramTypes).clone();
this.args = args;

View File

@ -13,11 +13,14 @@
*/
package com.mysema.query.types;
import javax.annotation.concurrent.Immutable;
/**
* @author tiwe
*
* @param <T>
*/
@Immutable
public class EntityPathImpl<T> extends PathImpl<T> implements EntityPath<T> {
private static final long serialVersionUID = -8536197750265693168L;

View File

@ -16,6 +16,7 @@ package com.mysema.query.types;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import com.mysema.query.Tuple;
@ -35,6 +36,7 @@ import com.mysema.query.Tuple;
*
* @param <T> expression type
*/
@Immutable
public abstract class MappingProjection<T> extends ExpressionBase<T> implements FactoryExpression<T> {
private static final long serialVersionUID = -948494350919774466L;

View File

@ -15,6 +15,8 @@ package com.mysema.query.types;
import java.util.List;
import javax.annotation.concurrent.Immutable;
import com.google.common.collect.ImmutableList;
@ -25,6 +27,7 @@ import com.google.common.collect.ImmutableList;
*
* @param <T> expression type
*/
@Immutable
public class OperationImpl<T> extends ExpressionBase<T> implements Operation<T> {
private static final long serialVersionUID = 4796432056083507588L;

View File

@ -15,11 +15,14 @@ package com.mysema.query.types;
import java.util.List;
import javax.annotation.concurrent.Immutable;
import com.google.common.collect.ImmutableList;
/**
* OperatorImpl is the default implementation of the {@link Operator} interface
*/
@Immutable
public final class OperatorImpl<T> implements Operator<T> {
private static final long serialVersionUID = -2435035383548549877L;

View File

@ -15,12 +15,15 @@ package com.mysema.query.types;
import java.io.Serializable;
import javax.annotation.concurrent.Immutable;
/**
* OrderSpecifier represents an order-by-element in a Query instance
*
* @param <T> related expression type
* @author tiwe
*/
@Immutable
public class OrderSpecifier<T extends Comparable> implements Serializable {
private static final long serialVersionUID = 3427652988262514678L;

View File

@ -15,6 +15,8 @@ package com.mysema.query.types;
import java.util.UUID;
import javax.annotation.concurrent.Immutable;
/**
* ParamExpressionImpl defines a parameter in a query with an optional name
*
@ -22,6 +24,7 @@ import java.util.UUID;
*
* @param <T> expression type
*/
@Immutable
public class ParamExpressionImpl<T> extends ExpressionBase<T> implements ParamExpression<T> {
private static final long serialVersionUID = -6872502615009012503L;

View File

@ -16,6 +16,7 @@ package com.mysema.query.types;
import java.lang.reflect.AnnotatedElement;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import com.mysema.util.ReflectionUtils;
@ -26,6 +27,7 @@ import com.mysema.util.ReflectionUtils;
*
* @param <T>
*/
@Immutable
public class PathImpl<T> extends ExpressionBase<T> implements Path<T> {
private static final long serialVersionUID = -2498447742798348162L;

View File

@ -16,6 +16,7 @@ package com.mysema.query.types;
import java.io.Serializable;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import com.google.common.base.Objects;
@ -24,6 +25,7 @@ import com.google.common.base.Objects;
*
* @author tiwe
*/
@Immutable
public final class PathMetadata<T> implements Serializable{
private static final long serialVersionUID = -1055994185028970065L;

View File

@ -14,6 +14,7 @@
package com.mysema.query.types;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import com.google.common.collect.ImmutableList;
@ -23,7 +24,8 @@ import com.google.common.collect.ImmutableList;
* @author tiwe
*
*/
public class PredicateOperation extends OperationImpl<Boolean> implements Predicate{
@Immutable
public final class PredicateOperation extends OperationImpl<Boolean> implements Predicate{
private static final long serialVersionUID = -5371430939203772072L;

View File

@ -14,6 +14,7 @@
package com.mysema.query.types;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import com.google.common.collect.ImmutableList;
@ -23,6 +24,7 @@ import com.google.common.collect.ImmutableList;
* @author tiwe
*
*/
@Immutable
public class PredicateTemplate extends TemplateExpressionImpl<Boolean> implements Predicate{
private static final long serialVersionUID = -5371430939203772072L;

View File

@ -14,7 +14,6 @@
package com.mysema.query.types;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;

View File

@ -16,6 +16,8 @@ package com.mysema.query.types;
import java.util.Arrays;
import java.util.List;
import javax.annotation.concurrent.Immutable;
import com.google.common.collect.ImmutableList;
import com.mysema.query.Tuple;
@ -36,6 +38,7 @@ import com.mysema.query.Tuple;
* @author tiwe
*
*/
@Immutable
public class QTuple extends ExpressionBase<Tuple> implements FactoryExpression<Tuple> {
private final class TupleImpl implements Tuple {

View File

@ -13,6 +13,8 @@
*/
package com.mysema.query.types;
import javax.annotation.concurrent.Immutable;
import com.mysema.query.QueryMetadata;
/**
@ -21,6 +23,7 @@ import com.mysema.query.QueryMetadata;
* @author tiwe
*
*/
@Immutable
public class SubQueryExpressionImpl<T> extends ExpressionBase<T> implements SubQueryExpression<T> {
private static final long serialVersionUID = 6775967804458163L;

View File

@ -16,7 +16,10 @@ package com.mysema.query.types;
import java.io.Serializable;
import java.util.List;
import javax.annotation.concurrent.Immutable;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
/**
* Template for {@link Operation}, {@link TemplateExpression} and {@link Path} serialization
@ -24,10 +27,12 @@ import com.google.common.base.Function;
* @author tiwe
*
*/
@Immutable
public final class Template implements Serializable {
private static final long serialVersionUID = -1697705745769542204L;
@Immutable
public static abstract class Element implements Serializable {
private static final long serialVersionUID = 3396877288101929387L;
@ -163,11 +168,11 @@ public final class Template implements Serializable {
}
private final List<Element> elements;
private final ImmutableList<Element> elements;
private final String template;
Template(String template, List<Element> elements) {
Template(String template, ImmutableList<Element> elements) {
this.template = template;
this.elements = elements;
}

View File

@ -15,6 +15,8 @@ package com.mysema.query.types;
import java.util.List;
import javax.annotation.concurrent.Immutable;
import com.google.common.collect.ImmutableList;
/**
@ -24,6 +26,7 @@ import com.google.common.collect.ImmutableList;
*
* @param <T> expression type
*/
@Immutable
public class TemplateExpressionImpl<T> extends ExpressionBase<T> implements TemplateExpression<T> {
private static final long serialVersionUID = 6951623726800809083L;

View File

@ -13,9 +13,7 @@
*/
package com.mysema.query.types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
@ -53,7 +51,7 @@ public class TemplateFactory {
return cache.get(template);
}else{
Matcher m = elementPattern.matcher(template);
List<Element> elements = new ArrayList<Template.Element>();
final ImmutableList.Builder<Element> elements = ImmutableList.builder();
int end = 0;
while (m.find()) {
if (m.start() > end) {
@ -122,8 +120,7 @@ public class TemplateFactory {
if (end < template.length()) {
elements.add(new Template.StaticText(template.substring(end)));
}
elements = ImmutableList.copyOf(elements);
Template rv = new Template(template, elements);
Template rv = new Template(template, elements.build());
cache.put(template, rv);
return rv;
}