Performs all of the necessary type conversions, then calls on the
appropriate operator.
485968
public static Object applyRelationalOperator
            (Object pLeft,
             Object pRight,
             RelationalOperator pOperator,
             Logger pLogger)
            throws ELException {
        if (isFloatingPointType(pLeft) ||
                isFloatingPointType(pRight)) {
            double left =
                    coerceToPrimitiveNumber(pLeft, Double.class, pLogger).
                            doubleValue();
            double right =
                    coerceToPrimitiveNumber(pRight, Double.class, pLogger).
                            doubleValue();
            return
                    PrimitiveObjects.getBoolean(pOperator.apply(left, right, pLogger));
        } else if (isIntegerType(pLeft) ||
                isIntegerType(pRight)) {
            long left =
                    coerceToPrimitiveNumber(pLeft, Long.class, pLogger).
                            longValue();
            long right =
                    coerceToPrimitiveNumber(pRight, Long.class, pLogger).
                            longValue();
            return
                    PrimitiveObjects.getBoolean(pOperator.apply(left, right, pLogger));
        } else if (pLeft instanceof String ||
                pRight instanceof String) {
            String left = coerceToString(pLeft, pLogger);
            String right = coerceToString(pRight, pLogger);
            return
                    PrimitiveObjects.getBoolean(pOperator.apply(left, right, pLogger));
        } else if (pLeft instanceof Comparable) {
            try {
                int result = ((Comparable) pLeft).compareTo(pRight);
                return
                        PrimitiveObjects.getBoolean
                                (pOperator.apply(result, -result, pLogger));
            }
            catch (Exception exc) {
                if (pLogger.isLoggingError()) {
                    pLogger.logError
                            (Constants.COMPARABLE_ERROR,
                                    exc,
                                    pLeft.getClass().getName(),
                                    (pRight == null) ? "null" : pRight.getClass().getName(),
                                    pOperator.getOperatorSymbol());
                }
                return Boolean.FALSE;
            }
        } else if (pRight instanceof Comparable) {
            try {
                int result = ((Comparable) pRight).compareTo(pLeft);
                return
                        PrimitiveObjects.getBoolean
                                (pOperator.apply(-result, result, pLogger));
            }
            catch (Exception exc) {
                if (pLogger.isLoggingError()) {
                    pLogger.logError
                            (Constants.COMPARABLE_ERROR,
                                    exc,
                                    pRight.getClass().getName(),
                                    (pLeft == null) ? "null" : pLeft.getClass().getName(),
                                    pOperator.getOperatorSymbol());
                }
                return Boolean.FALSE;
            }
        } else {
            if (pLogger.isLoggingError()) {
                pLogger.logError
                        (Constants.ARITH_OP_BAD_TYPE,
                                pOperator.getOperatorSymbol(),
                                pLeft.getClass().getName(),
                                pRight.getClass().getName());
            }
            return Boolean.FALSE;
        }
    }
134136
@SuppressWarnings("unchecked")
    private <T> ConversionStatus convertGenericClazz(String rawString, Class<T> type, TypeVariable<?> typeVariable) {
        ConversionStatus status = new ConversionStatus();
        AnnotatedType[] bounds = typeVariable.getAnnotatedBounds();
        for (AnnotatedType bound : bounds) {
            Type bType = bound.getType();
            if (bType instanceof Class) {
                Class<?> bClazz = (Class<?>) bType;
                if (bClazz.isAssignableFrom(type)) {
                    T converted = (T) convert(rawString, typeVariable);
                    status.setConverted(converted);
                    break;
                }
            }
        }

        return status;
    }
262983
public void convert(String fromVariable, TypeMirror to) throws IOException, IllegalConversionException
    {
        TypeMirror from = getLocalType(fromVariable);
        if (Typ.isAssignable(from, to))
        {
            tload(fromVariable);
            checkcast(to);
            return;
        }
        if (to.getKind() == TypeKind.DECLARED)
        {
            DeclaredType dt = (DeclaredType) to;
            TypeElement te = (TypeElement) dt.asElement();
            ExecutableElement c = El.getConstructor(te, from);
            if (c != null)
            {
                anew(te);
                dup();
                tload(fromVariable);
                invokespecial(c);
                return;
            }
            ExecutableElement m = El.getMethod(te, "valueOf", from);
            if (m != null && m.getModifiers().contains(Modifier.STATIC) && Typ.isAssignable(m.getReturnType(), to))
            {
                tload(fromVariable);
                invokestatic(m);
                return;
            }
        }
        if (from.getKind() == TypeKind.DECLARED && Typ.isPrimitive(to))
        {
            DeclaredType dt = (DeclaredType) from;
            TypeElement te = (TypeElement) dt.asElement();
            String str = to.getKind().name().toLowerCase() + "Value";
            ExecutableElement m = El.getMethod(te, str);
            // xxxValue()
            // xxxValue()
            if (m != null && Typ.isAssignable(m.getReturnType(), to))
            {
                tload(fromVariable);
                invokevirtual(m);
                return;
            }
        }
        if (Typ.isPrimitive(from))
        {
            switch (from.getKind())
            {
                case BYTE:
                case CHAR:
                case SHORT:
                case INT:
                    switch (to.getKind())
                    {
                        case BYTE:
                        case CHAR:
                        case SHORT:
                        case INT:
                        case LONG:
                        case FLOAT:
                        case DOUBLE:
                            tload(fromVariable);
                            i2t();
                            break;
                        default:
                            throw new IllegalConversionException("Cannot convert from " + from + " to " + to);
                    }
                    break;
                case LONG:
                    switch (to.getKind())
                    {
                        case BYTE:
                        case CHAR:
                        case SHORT:
                        case INT:
                            tload(fromVariable);
                            l2t();
                            break;
                        case FLOAT:
                        case DOUBLE:
                            tload(fromVariable);
                            l2t();
                            break;
                        default:
                            throw new IllegalConversionException("Cannot convert from " + from + " to " + to);
                    }
                    break;
                case FLOAT:
                    switch (to.getKind())
                    {
                        case BYTE:
                        case CHAR:
                        case SHORT:
                        case INT:
                            tload(fromVariable);
                            f2t();
                            break;
                        case LONG:
                        case DOUBLE:
                            tload(fromVariable);
                            f2t();
                            break;
                        default:
                            throw new IllegalConversionException("Cannot convert from " + from + " to " + to);
                    }
                    break;
                case DOUBLE:
                    switch (to.getKind())
                    {
                        case BYTE:
                        case CHAR:
                        case SHORT:
                        case INT:
                            tload(fromVariable);
                            d2t();
                            break;
                        case LONG:
                        case FLOAT:
                            tload(fromVariable);
                            d2t();
                            break;
                        default:
                            throw new IllegalConversionException("Cannot convert from " + from + " to " + to);
                    }
                    break;
                default:
                    throw new IllegalConversionException("Cannot convert from " + from + " to " + to);
            }
        }
        throw new IllegalConversionException("!Cannot convert from " + from+" "+from.getKind() + " to " + to+" "+to.getKind());
    }
456197
def Compile(self, filter_implemention):
    """"""
    return self.operator_method(self.attribute_obj, filter_implemention,
                                *self.args)
1081000
public <T> T convert(Type type, Object value, T defaultValue) throws ConvertException {
		return convert(type, value, defaultValue, true);
	}
1036624
private Class<?> convertType(Class<?> old)
   {
      if (Boolean.class.equals(old))
      {
         return boolean.class;
      }
      else if (boolean.class.equals(old))
      {
         return Boolean.class;
      }
      else if (Byte.class.equals(old))
      {
         return byte.class;
      }
      else if (byte.class.equals(old))
      {
         return Byte.class;
      }
      else if (Short.class.equals(old))
      {
         return short.class;
      }
      else if (short.class.equals(old))
      {
         return Short.class;
      }
      else if (Integer.class.equals(old))
      {
         return int.class;
      }
      else if (int.class.equals(old))
      {
         return Integer.class;
      }
      else if (Long.class.equals(old))
      {
         return long.class;
      }
      else if (long.class.equals(old))
      {
         return Long.class;
      }
      else if (Float.class.equals(old))
      {
         return float.class;
      }
      else if (float.class.equals(old))
      {
         return Float.class;
      }
      else if (Double.class.equals(old))
      {
         return double.class;
      }
      else if (double.class.equals(old))
      {
         return Double.class;
      }
      else if (Character.class.equals(old))
      {
         return char.class;
      }
      else if (char.class.equals(old))
      {
         return Character.class;
      }

      return null;
   }
1329714
public void iterateAllRegisteredTypeConverters (@Nonnull final ITypeConverterCallback aCallback)
  {
    // Create a copy of the map
    final Map <Class <?>, Map <Class <?>, ITypeConverter <?, ?>>> aCopy = m_aRWLock.readLocked ( () -> new CommonsHashMap <> (m_aConverter));

    // And iterate the copy
    outer: for (final Map.Entry <Class <?>, Map <Class <?>, ITypeConverter <?, ?>>> aSrcEntry : aCopy.entrySet ())
    {
      final Class <?> aSrcClass = aSrcEntry.getKey ();
      for (final Map.Entry <Class <?>, ITypeConverter <?, ?>> aDstEntry : aSrcEntry.getValue ().entrySet ())
        if (aCallback.call (aSrcClass, aDstEntry.getKey (), aDstEntry.getValue ()).isBreak ())
          break outer;
    }
  }
688592
def CreateTypes(self, allTypes):
      
      enumTypes, dataTypes, managedTypes = self._ConvertAllTypes(allTypes)
      self._CreateAllTypes(enumTypes, dataTypes, managedTypes)
526504
@Override
    public boolean supportsConvert(int fromType, int toType) throws SQLException {
        checkClosed();
        switch (fromType) {
        /*
         * ALL types can be converted to VARCHAR /VoltType.String
         */
        case java.sql.Types.VARCHAR:
        case java.sql.Types.VARBINARY:
        case java.sql.Types.TIMESTAMP:
        case java.sql.Types.OTHER:
            switch (toType) {
            case java.sql.Types.VARCHAR:
                return true;

            default:
                return false;
            }
        case java.sql.Types.TINYINT:
        case java.sql.Types.SMALLINT:
        case java.sql.Types.INTEGER:
        case java.sql.Types.BIGINT:
        case java.sql.Types.FLOAT:
        case java.sql.Types.DECIMAL:
            switch (toType) {
            case java.sql.Types.VARCHAR:
            case java.sql.Types.TINYINT:
            case java.sql.Types.SMALLINT:
            case java.sql.Types.INTEGER:
            case java.sql.Types.BIGINT:
            case java.sql.Types.FLOAT:
            case java.sql.Types.DECIMAL:
                return true;

            default:
                return false;
            }
        default:
            return false;
        }
    }
460854
private static Converter<List<String>, Object> createListConverter(Type resultType) {
    // Use boxed type if raw type is primitive type. Otherwise the type won't change.
    Class<?> resultClass = getRawClass(resultType);

    // For string, just return the first value
    if (resultClass == String.class) {
      return new BasicConverter(defaultValue(resultClass)) {
        @Override
        protected Object convert(String value) throws Exception {
          return value;
        }
      };
    }

    // Creates converter based on the type

    // Primitive
    Converter<List<String>, Object> converter = createPrimitiveTypeConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // String constructor
    converter = createStringConstructorConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // Static string argument methods
    converter = createStringMethodConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // Collection
    converter = createCollectionConverter(resultType);
    if (converter != null) {
      return converter;
    }

    throw new IllegalArgumentException("Unsupported type " + resultType + " of type class " + resultType.getClass());
  }
451329
def _cast_to_type(self, value):
        
        try:
            return int(value)
        except (ValueError, TypeError):
            self.fail('invalid', value=value)
168117
private Object convert(Object value, String type) {
        if (EnumRuleType.STRING.equals(type)) {
            if (!(value instanceof String)) {
                return String.valueOf(value);
            }
        } else if (EnumRuleType.DOUBLE.equals(type)) {
            if (!(value instanceof Double)) {
                if (value instanceof Number) {
                    return NumberUtils.convertNumberToTargetClass((Number) value, Double.class);
                } else {
                    return NumberUtils.parseNumber(value.toString(), Double.class);
                }
            }
        } else if (EnumRuleType.INTEGER.equals(type)) {
            if (!(value instanceof Integer)) {
                if (value instanceof Number) {
                    return NumberUtils.convertNumberToTargetClass((Number) value, Integer.class);
                } else {
                    return NumberUtils.parseNumber(value.toString(), Integer.class);
                }
            }
        }
        return value;
    }
640369
def casting_operators(
            self,
            name=None,
            function=None,
            return_type=None,
            arg_types=None,
            header_dir=None,
            header_file=None,
            recursive=None,
            allow_empty=None):
        """"""
        return (
            self._find_multiple(
                self._impl_matchers[scopedef_t.casting_operator],
                name=name,
                function=function,
                decl_type=self._impl_decl_types[
                    scopedef_t.casting_operator],
                return_type=return_type,
                arg_types=arg_types,
                header_dir=header_dir,
                header_file=header_file,
                recursive=recursive,
                allow_empty=allow_empty)
        )
505921
protected final CALC operator(Class<? extends Operator> operator, String value, char decimalSeparator) {
        return operator(operator, new Num(value, decimalSeparator));
    }
389770
public static <T> SimpleOperation<T> operation(Class<? extends T> type, Operator operator,
            Expression<?>... args) {
        return simpleOperation(type, operator, args);

    }
434946
private void processTypeVariables(TypeVariable<?>[] variables, Type[] values) {
        for (int i = 0; i < variables.length; i++) {
            processTypeVariable(variables[i], values[i]);
        }
    }
527475
public function process()
    {
        $operands = $this->getOperands();

        if ($operands->containsNull() === true) {
            return null;
        }

        if ($operands->exclusivelySingle() === false) {
            $msg = "The Subtract operator only accepts operands with a single cardinality";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        if ($operands->exclusivelyNumeric() === false) {
            $msg = "The Subtract operator only accepts operands with a baseType of integer or float";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

        $operand1 = $operands[0];
        $operand2 = $operands[1];

        $subtract = $operand1->getValue() - $operand2->getValue();

        return (is_int($subtract) === true) ? new QtiInteger($subtract) : new QtiFloat($subtract);
    }