/** * {@inheritDoc} */ @Override public Class<?> getType() { if (op == COUNT) { return Long.class; } return obj.getType(); }
/** * {@inheritDoc} */ @Override public int getApproximateType() { if (obj.getType().equals(UnknownTypeValue.class)) { return obj.getApproximateType(); } else { throw new ClassCastException("getApproximateType called when type is known"); } } }
/** * {@inheritDoc} */ @Override public void youAreType(Class<?> cls) { if (obj.getType().equals(UnknownTypeValue.class)) { obj.youAreType(cls); } else { throw new ClassCastException("youAreType called on function that already has type"); } }
if (op == ADD || op == SUBTRACT || op == MULTIPLY || op == DIVIDE || op == MODULO || op == GREATEST || op == LEAST) { if (Number.class.isAssignableFrom(arg1.getType()) && Number.class.isAssignableFrom(arg2.getType()) && arg1.getType().equals(arg2.getType())) { this.type = arg1.getType(); } else if (arg1.getType().equals(UnknownTypeValue.class) && (!(arg2.getType().equals(UnknownTypeValue.class)))) { arg1.youAreType(arg2.getType()); this.type = arg1.getType(); } else if (arg2.getType().equals(UnknownTypeValue.class) && (!(arg1.getType().equals(UnknownTypeValue.class)))) { arg2.youAreType(arg1.getType()); this.type = arg2.getType(); } else if ((arg1.getType().equals(UnknownTypeValue.class)) && (arg2.getType().equals(UnknownTypeValue.class))) { if (arg1.getApproximateType() != arg2.getApproximateType()) { throw new ClassCastException("Incompatible expression with unknown type" + " values"); throw new ClassCastException("Invalid arguments (" + arg1.getType() + ", " + arg2.getType() + ") for specified operation (" + getOpName(op) + ")"); if (arg1.getType().equals(UnknownTypeValue.class)) { arg1.youAreType(String.class); if (arg2.getType().equals(UnknownTypeValue.class)) { arg2.youAreType(String.class);
/** * {@inheritDoc} */ public int getApproximateType() { if (type.equals(UnknownTypeValue.class)) { return arg1.getApproximateType(); } else { throw new ClassCastException("getApproximateType called when type is known"); } }
/** * {@inheritDoc} */ public void youAreType(Class<?> cls) { if (type.equals(UnknownTypeValue.class)) { // Must be the numeric operation arg1.youAreType(cls); arg2.youAreType(cls); type = cls; } else { throw new ClassCastException("youAreType called on QueryExpression that already has " + "type"); } }
if (op == ADD || op == SUBTRACT || op == MULTIPLY || op == DIVIDE || op == MODULO || op == GREATEST || op == LEAST) { if (Number.class.isAssignableFrom(arg1.getType()) && Number.class.isAssignableFrom(arg2.getType()) && arg1.getType().equals(arg2.getType())) { this.type = arg1.getType(); } else if (arg1.getType().equals(UnknownTypeValue.class) && (!(arg2.getType().equals(UnknownTypeValue.class)))) { arg1.youAreType(arg2.getType()); this.type = arg1.getType(); } else if (arg2.getType().equals(UnknownTypeValue.class) && (!(arg1.getType().equals(UnknownTypeValue.class)))) { arg2.youAreType(arg1.getType()); this.type = arg2.getType(); } else if ((arg1.getType().equals(UnknownTypeValue.class)) && (arg2.getType().equals(UnknownTypeValue.class))) { if (arg1.getApproximateType() != arg2.getApproximateType()) { throw new ClassCastException("Incompatible expression with unknown type" + " values"); throw new ClassCastException("Invalid arguments (" + arg1.getType() + ", " + arg2.getType() + ") for specified operation (" + getOpName(op) + ")"); if (arg1.getType().equals(UnknownTypeValue.class)) { arg1.youAreType(String.class); if (arg2.getType().equals(UnknownTypeValue.class)) { arg2.youAreType(String.class);
/** * {@inheritDoc} */ public int getApproximateType() { if (type.equals(UnknownTypeValue.class)) { return arg1.getApproximateType(); } else { throw new ClassCastException("getApproximateType called when type is known"); } }
/** * {@inheritDoc} */ public void youAreType(Class<?> cls) { if (type.equals(UnknownTypeValue.class)) { // Must be the numeric operation arg1.youAreType(cls); arg2.youAreType(cls); type = cls; } else { throw new ClassCastException("youAreType called on QueryExpression that already has " + "type"); } }
/** * {@inheritDoc} */ @Override public Class<?> getType() { if (op == COUNT) { return Long.class; } return obj.getType(); }
/** * {@inheritDoc} */ @Override public void youAreType(Class<?> cls) { if (obj.getType().equals(UnknownTypeValue.class)) { obj.youAreType(cls); } else { throw new ClassCastException("youAreType called on function that already has type"); } }
/** * {@inheritDoc} */ @Override public int getApproximateType() { if (obj.getType().equals(UnknownTypeValue.class)) { return obj.getApproximateType(); } else { throw new ClassCastException("getApproximateType called when type is known"); } } }
private void constructNonCount(QueryEvaluable qe, int newOp) { if (!(op == SUM || op == AVERAGE || op == MIN || op == MAX || op == STDDEV || op == CEIL || op == FLOOR || op == ROUND)) { throw new IllegalArgumentException("Invalid operation for specified argument"); } if (!(Number.class.isAssignableFrom(qe.getType()) || qe.getType().equals(UnknownTypeValue.class))) { throw new IllegalArgumentException("Invalid argument type for specified operation"); } obj = qe; this.op = newOp; }
/** * Constructs a String QueryExpression to perform upper and lowercase conversions. * * @param op the required operation * @param arg the String argument * @throws IllegalArgumentException if there is a mismatch between the argument and operation */ public QueryExpression(int op, QueryEvaluable arg) { if (!(op == UPPER || op == LOWER)) { throw new IllegalArgumentException("Invalid operation for specified arguments"); } if (arg.getType().equals(UnknownTypeValue.class)) { arg.youAreType(String.class); } else if (!arg.getType().equals(String.class) && !arg.getType().equals(org.intermine.objectstore.query.ClobAccess.class)) { throw new ClassCastException("Invalid argument (" + arg.getType() + ") for " + (op == UPPER ? "UPPER()" : "LOWER()") + " operation"); } arg1 = arg; this.op = op; type = String.class; }
private void constructNonCount(QueryEvaluable qe, int newOp) { if (!(op == SUM || op == AVERAGE || op == MIN || op == MAX || op == STDDEV || op == CEIL || op == FLOOR || op == ROUND)) { throw new IllegalArgumentException("Invalid operation for specified argument"); } if (!(Number.class.isAssignableFrom(qe.getType()) || qe.getType().equals(UnknownTypeValue.class))) { throw new IllegalArgumentException("Invalid argument type for specified operation"); } obj = qe; this.op = newOp; }
/** * Constructs a String QueryExpression to perform upper and lowercase conversions. * * @param op the required operation * @param arg the String argument * @throws IllegalArgumentException if there is a mismatch between the argument and operation */ public QueryExpression(int op, QueryEvaluable arg) { if (!(op == UPPER || op == LOWER)) { throw new IllegalArgumentException("Invalid operation for specified arguments"); } if (arg.getType().equals(UnknownTypeValue.class)) { arg.youAreType(String.class); } else if (!arg.getType().equals(String.class) && !arg.getType().equals(org.intermine.objectstore.query.ClobAccess.class)) { throw new ClassCastException("Invalid argument (" + arg.getType() + ") for " + (op == UPPER ? "UPPER()" : "LOWER()") + " operation"); } arg1 = arg; this.op = op; type = String.class; }
/** * Constructor for functions that take two parameters. * @param qe The first parameter. * @param op The operation code. * @param qe2 The second parameter. */ public QueryFunction(QueryEvaluable qe, int op, QueryEvaluable qe2) { this(qe, op); if ((qe instanceof QueryField) || (qe instanceof QueryExpression) || (qe instanceof QueryCast) || (qe instanceof QueryForeignKey)) { if (!(Integer.class.isAssignableFrom(qe2.getType()) || qe2.getType().equals(UnknownTypeValue.class))) { throw new IllegalArgumentException("Invalid parameter argument type for " + "specified operation"); } obj2 = qe2; } else { throw new IllegalArgumentException("Parameter Value unsuitable for QueryFunction: " + qe2); } }
throw new NullPointerException("Parent parameter cannot be null"); if (start.getType().equals(UnknownTypeValue.class)) { start.youAreType(Integer.class); if (end.getType().equals(UnknownTypeValue.class)) { end.youAreType(Integer.class); if (!Integer.class.equals(start.getType())) { throw new IllegalArgumentException("Start parameter (" + start.getType() + ") is not an Integer"); if (!Integer.class.equals(end.getType())) { throw new IllegalArgumentException("End parameter (" + end.getType() + ") is not an Integer");
/** * Constructor for functions that take two parameters. * @param qe The first parameter. * @param op The operation code. * @param qe2 The second parameter. */ public QueryFunction(QueryEvaluable qe, int op, QueryEvaluable qe2) { this(qe, op); if ((qe instanceof QueryField) || (qe instanceof QueryExpression) || (qe instanceof QueryCast) || (qe instanceof QueryForeignKey)) { if (!(Integer.class.isAssignableFrom(qe2.getType()) || qe2.getType().equals(UnknownTypeValue.class))) { throw new IllegalArgumentException("Invalid parameter argument type for " + "specified operation"); } obj2 = qe2; } else { throw new IllegalArgumentException("Parameter Value unsuitable for QueryFunction: " + qe2); } }
if (qe1.getType().equals(UnknownTypeValue.class) && (!(qe2.getType().equals(UnknownTypeValue.class)))) { qe1.youAreType(qe2.getType()); if (qe2.getType().equals(UnknownTypeValue.class) && (!(qe1.getType().equals(UnknownTypeValue.class)))) { qe2.youAreType(qe1.getType()); if (!validComparison(qe1.getType(), op, qe2.getType())) { throw new IllegalArgumentException("Invalid constraint: " + qe1 + " (a " + qe1.getType().getName() + ") " + op + " " + qe2 + " (a " + qe2.getType().getName() + ")");