Java Reflection Primitive isNumericType(Class aNumberClass)

Here you can find the source of isNumericType(Class aNumberClass)

Description

Determines if the given class is numeric.

License

Open Source License

Return

true if the given class is derived from Number.

Declaration

public static boolean isNumericType(Class aNumberClass) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright 2000, 2006 Visual Systems Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License version 2
 * which accompanies this distribution in a file named "COPYING".
 * // w ww. j  av a  2s.c  om
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *      
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *      
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *******************************************************************************/

import java.util.HashMap;

import java.util.Map;

public class Main {
    /** Key is a Number Class, Value is an Integer indicating rank. */
    private static final Map<Class<?>, Integer> NUMBER_RANK_MAP = new HashMap<Class<?>, Integer>();

    /**
     * Determines if the given class is numeric. 
     * 
     * @return true if the given class is derived from Number.
     */
    public static boolean isNumericType(Class aNumberClass) {
        return NUMBER_RANK_MAP.get(aNumberClass) != null;
    }
}

Related

  1. isNumber(Class type)
  2. isNumber(Class type)
  3. isNumber(Class clazz)
  4. isNumeric(Class operandClass)
  5. isNumericPrimitive(Class type)
  6. isPrimitive(Class c)
  7. isPrimitive(Class clazz)
  8. isPrimitiveClass(Class clazz)
  9. isPrimitiveClass(Class cls)