Fix cyclic dependency

This commit is contained in:
Timo Westkämper 2014-12-02 19:44:31 +02:00
parent 403cbe4cec
commit 9b7fef5a07
3 changed files with 13 additions and 25 deletions

View File

@ -13,13 +13,12 @@
*/
package com.mysema.query.types;
import javax.annotation.concurrent.Immutable;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.lang.reflect.Field;
import java.util.List;
import javax.annotation.concurrent.Immutable;
import com.google.common.collect.ImmutableList;
@ -104,9 +103,12 @@ public class OperationImpl<T> extends ExpressionBase<T> implements Operation<T>
Field field = OperationImpl.class.getDeclaredField("operator");
field.setAccessible(true);
field.set(this, OperatorImpl.OPS.get(operator.getId()));
} catch (Exception e) {
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -106,7 +106,9 @@ public final class PathMetadata<T> implements Serializable{
Field field = PathMetadata.class.getDeclaredField("hashCode");
field.setAccessible(true);
field.set(this, 31 * element.hashCode() + pathType.hashCode());
} catch (Exception e) {
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}

View File

@ -13,11 +13,10 @@
*/
package com.mysema.query.types.expr;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.lang.reflect.Field;
import com.mysema.query.types.*;
import com.mysema.query.types.Expression;
import com.mysema.query.types.Ops;
import com.mysema.query.types.Path;
import com.mysema.query.types.PathImpl;
/**
* DslExpression is the base class for DSL expressions, but {@link SimpleExpression} is the base class
@ -32,11 +31,8 @@ public abstract class DslExpression<T> implements Expression<T> {
protected final Expression<T> mixin;
protected transient final int hashCode;
public DslExpression(Expression<T> mixin) {
this.mixin = mixin;
this.hashCode = mixin.hashCode();
}
@Override
@ -70,7 +66,7 @@ public abstract class DslExpression<T> implements Expression<T> {
@Override
public final int hashCode() {
return hashCode;
return mixin.hashCode();
}
@Override
@ -78,16 +74,4 @@ public abstract class DslExpression<T> implements Expression<T> {
return mixin.toString();
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
try {
ois.defaultReadObject();
Field field = DslExpression.class.getDeclaredField("hashCode");
field.setAccessible(true);
field.set(this, mixin.hashCode());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}