static Object convert(Object value, Type destinationType) {
    if (value == null) {
      return null;
    }

    if (value.getClass() == destinationType) {
      // no need to cast
      return value;
    }

    // try to convert between numbers
    if (value instanceof Number) {
      Primitive primitive = Primitive.ofAny(destinationType);
      if (primitive != null && !primitive.boxClass.isInstance(value)) {
        // cast
        return primitive.cast((Number) value);
      }
    }

    // don't know what to do with this value
    // return AS IS
    return value;
  }
Used to convert between types. Sometimes geode backend returns different types for aggregate functions like AVG / MIN / MAX.
Eg. Long vs Integer
criteria/geode/src/org/immutables/criteria/geode/Geodes.java