public TypedOperand castToCommonType()

in lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/TypedOperand.java [159:190]


  public TypedOperand castToCommonType(final VisitorOperand otherOperand) throws ODataApplicationException {
    final TypedOperand other = otherOperand.asTypedOperand();
    final EdmType oType = other.getType();
    
    // In case of numberic values make sure that the EDM type is equal, check also the java type.
    // It is possible that there is an conversion even if the same EdmType is provided.
    // For example consider an Edm.Int32 (internal Integer) and an Edm.Int16 (internal Short) value:
    // shortInstance.equals(intInstance) will always be false!
    if (type == oType && value != null && other.getValue() != null
        && value.getClass() == other.getValue().getClass()) {
      return this;
    } else if (is(primNull) || other.is(primNull)) {
      return this;
    }

    if (type.equals(primDouble) || oType.equals(primDouble)) {
      return (value instanceof ArrayList) ? asTypedOperandForCollection(primDouble) : asTypedOperand(primDouble);
    } else if (type.equals(primSingle) || oType.equals(primSingle)) {
      return (value instanceof ArrayList) ? asTypedOperandForCollection(primSingle) : asTypedOperand(primSingle);
    } else if (type.equals(primDecimal) || oType.equals(primDecimal)) {
      return (value instanceof ArrayList) ? asTypedOperandForCollection(primDecimal) : asTypedOperand(primDecimal);
    } else if (type.equals(primInt64) || oType.equals(primInt64)) {
      return (value instanceof ArrayList) ? asTypedOperandForCollection(primInt64) : asTypedOperand(primInt64);
    } else if (type.equals(primInt32) || oType.equals(primInt32)) {
      return (value instanceof ArrayList) ? asTypedOperandForCollection(primInt32) : asTypedOperand(primInt32);
    } else if (type.equals(primInt16) || oType.equals(primInt16)) {
      return (value instanceof ArrayList) ? asTypedOperandForCollection(primInt16) : asTypedOperand(primInt16);
    } else {
      return (value instanceof ArrayList) ? asTypedOperandForCollection((EdmPrimitiveType) type) : 
        asTypedOperand((EdmPrimitiveType) type);
    }
  }