Java Reflection Primitive isNumeric(Class operandClass)

Here you can find the source of isNumeric(Class operandClass)

Description

Determine whether the operand of type operandClass can be a numeric operand

License

Apache License

Parameter

Parameter Description
operandClass the class type of the numeric operand

Return

whether the operand of type operand Class can be a numeric operand

Declaration

public static boolean isNumeric(Class operandClass) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.HashMap;

import java.util.Map;

public class Main {
    private static Map primitiveLangClassMap = new HashMap();

    /**// ww  w .  ja  va  2  s . c o  m
      * Determine whether the operand of type operandClass can be a numeric
      * operand
      * 
      * @param operandClass
      *            the class type of the numeric operand
      * @return whether the operand of type operand Class can be a numeric
      *         operand
      */
    public static boolean isNumeric(Class operandClass) {
        if (operandClass == null || !operandClass.isPrimitive() || operandClass == boolean.class
                || operandClass == void.class) {
            if (primitiveLangClassMap.containsKey(operandClass)) {
                return true;
            }
            return false;
        }

        return true;
    }
}

Related

  1. isBoxed(Class boxedClass, Class primitiveClass)
  2. isExtPrimitive(Class clazz)
  3. isNumber(Class type)
  4. isNumber(Class type)
  5. isNumber(Class clazz)
  6. isNumericPrimitive(Class type)
  7. isNumericType(Class aNumberClass)
  8. isPrimitive(Class c)
  9. isPrimitive(Class clazz)