private void testAndSetResult(final Number theResult) { if (_result == null) _result = theResult; else { final NumericComparisonVisitor visitor = new NumericComparisonVisitor(); final NumericPromotion promoter = new NumericPromotion(); promoter.promote(_result, theResult); promoter.accept(visitor); if (visitor.getComparison() == 0) _result = theResult; else _result = null; } }
@Override protected boolean test(final Literal a, final Literal b) { final Object aval = a.getValue(); final Object bval = b.getValue(); // Numbers are a special case, since they can be promoted from Integers and Decimals to Floats and Doubles. if (aval instanceof Number && bval instanceof Number) { final NumericPromotion promoter = new NumericPromotion(); final Number anum = (Number) aval; final Number bnum = (Number) bval; promoter.promote(anum, bnum); final NumericComparisonVisitor visitor = new NumericComparisonVisitor(); promoter.accept(visitor); if (visitor.getComparison() == 0) return true ^ _flip; return false ^ _flip; } if (a.getValue() != null && b.getValue() != null) return (aval.getClass().equals(bval.getClass()) && aval.equals(bval)) ^ _flip; return false; } }
@Override protected boolean test(final Literal a, final Literal b) { final Object aval = a.getValue(); final Object bval = b.getValue(); // Numbers are a special case, since they can be promoted from Integers and Decimals to Floats and Doubles. if (aval instanceof Number && bval instanceof Number) { final NumericPromotion promoter = new NumericPromotion(); final Number anum = (Number) aval; final Number bnum = (Number) bval; promoter.promote(anum, bnum); final NumericComparisonVisitor visitor = new NumericComparisonVisitor(); promoter.accept(visitor); if (visitor.getComparison() == 0) return true ^ _flip; return false ^ _flip; } if (a.getValue() != null && b.getValue() != null) return (aval.getClass().equals(bval.getClass()) && aval.equals(bval)) ^ _flip; return false; } }
private void testAndSetResult(final Number theResult) { if (_result == null) _result = theResult; else { final NumericComparisonVisitor visitor = new NumericComparisonVisitor(); final NumericPromotion promoter = new NumericPromotion(); promoter.promote(_result, theResult); promoter.accept(visitor); if (visitor.getComparison() == 0) _result = theResult; else _result = null; } }
promoter.accept(visitor); return comparesWell(visitor.getComparison());
promoter.accept(visitor); return comparesWell(visitor.getComparison());