public static Pair < Object , Object > toSame ( Object value1 , Object value2 , EvaluationContext ctx ) { if ( value1 . getClass ( ) . equals ( value2 . getClass ( ) ) ) { return new ImmutablePair <> ( value1 , value2 ) ; } try { // try converting to two decimals return new ImmutablePair < Object , Object > ( toDecimal ( value1 , ctx ) , toDecimal ( value2 , ctx ) ) ; } catch ( EvaluationError ex ) { } try { // try converting to two dates Temporal d1 = toDateOrDateTime ( value1 , ctx ) ; Temporal d2 = toDateOrDateTime ( value2 , ctx ) ; if ( ! value1 . getClass ( ) . equals ( value2 . getClass ( ) ) ) { d1 = toDateTime ( d1 , ctx ) ; d2 = toDateTime ( d2 , ctx ) ; } return new ImmutablePair < Object , Object > ( d1 , d2 ) ; } catch ( EvaluationError ex ) { } // try converting to two strings return new ImmutablePair < Object , Object > ( toString ( value1 , ctx ) , toString ( value2 , ctx ) ) ; }
Converts a pair of arguments to their most - likely types . This deviates from Excel which doesn t auto convert values but is necessary for us to intuitively handle contact fields which don t use the correct value type