public Predicate comparisonPredAnalyse(Predicate toAnalyse) {
if (!(toAnalyse instanceof ComparisonPredicate))
return toAnalyse;
// Check if is Double or Integer
ComparisonPredicate compToAnalyse = (ComparisonPredicate) toAnalyse;
List<ValueExpression> followUps = compToAnalyse.getExpressions();
// if one of the previous change to Double
toAnalyse = getSameForDouble(toAnalyse);
compToAnalyse = (ComparisonPredicate) toAnalyse;
followUps = compToAnalyse.getExpressions();
ValueExpression leftPart = null;
try {
leftPart = combine(null, 0, followUps.get(0));
} catch (final Exception e) {
return toAnalyse;
}
ValueExpression rightPart = null;
try {
rightPart = combine(null, 0, followUps.get(1));
} catch (final Exception e) {
return toAnalyse;
}
boolean temp = false;
getInfo(leftPart, temp, 0);
temp = false;
getInfo(rightPart, temp, 1);
if (Parameter[0] == null)
Parameter[0] = new ValueSpecification<Double>(numConv, 1.0);
if (Parameter[1] == null)
Parameter[1] = new ValueSpecification<Double>(numConv, 1.0);
Parameter[0].inverseNumber();
ValueExpression fullClean = null;
if (CleanPart[0] != null) {
if (CleanPart[1] != null)
fullClean = new Subtraction<Double>(CleanPart[1], CleanPart[0]);
else if (CleanPart[1] == null) {
final ValueExpression temp1 = new ValueSpecification<Double>(numConv, 0.0);
fullClean = new Subtraction<Double>(temp1, CleanPart[0]);
}
} else if (CleanPart[0] == null)
if (CleanPart[1] != null)
fullClean = CleanPart[1];
else
fullClean = new ValueSpecification(numConv, 0.0);
fullClean = combine(null, 0, fullClean);
ValueExpression finalA = new Multiplication<Double>(Parameter[0], Parameter[1]);
finalA = combine(null, 0, finalA);
ValueExpression finalB = new Multiplication<Double>(Parameter[0], fullClean);
finalB = combine(null, 0, finalB);
final ValueExpression withVariable = new Multiplication<Double>(finalA, Variable[1]);
final ValueExpression finalRightPart = new Addition<Double>(withVariable, finalB);
Predicate finalPred;
if (Parameter[0].isNegative())
finalPred = new ComparisonPredicate(compToAnalyse.getOperator(true), Variable[0],
finalRightPart);
else
finalPred = new ComparisonPredicate(compToAnalyse.getOperator(false), Variable[0],
finalRightPart);
return finalPred;
}