Java Reflection Primitive convertToPrimitive(Class type)

Here you can find the source of convertToPrimitive(Class type)

Description

convert To Primitive

License

Open Source License

Declaration

public static final Class convertToPrimitive(Class type) 

Method Source Code

//package com.java2s;
/**   //w w  w .jav  a 2  s .c  om
 *  Copyright (c) 2005-2014 VedantaTree all rights reserved.
 * 
 *  This file is part of ExpressionOasis.
 *
 *  ExpressionOasis is free software. You can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  ExpressionOasis 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. IN NO EVENT SHALL 
 *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES 
 *  OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
 *  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
 *  OR OTHER DEALINGS IN THE SOFTWARE.See the GNU Lesser General Public License 
 *  for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with ExpressionOasis. If not, see <http://www.gnu.org/licenses/>.
 *  
 *  Please consider to contribute any enhancements to upstream codebase. 
 *  It will help the community in getting improved code and features, and 
 *  may help you to get the later releases with your changes.
 */

import java.util.HashMap;
import java.util.Map;

public class Main {
    private static Map<Class, Class> wrapperToprimitives = new HashMap<Class, Class>();

    public static final Class convertToPrimitive(Class type) {
        if (type == null || type.isPrimitive()) {
            throw new IllegalArgumentException(
                    "Given class type is wrong. Either it is null or is a primitive. given-class[" + type + "]");
        }
        return wrapperToprimitives.get(type);
    }
}

Related

  1. canCoerceLiteralNumberExpr(Class type)
  2. castToPrimitive(Object start, Class prim)
  3. convertPrimitiveToObjectClass(Class clazz)
  4. convertPrimitiveToWrapper(Class clazz)
  5. convertPrimitiveToWrapper(Class clazz)
  6. convertWrapperToPrimitive(Class clazz)
  7. createDefaultPrimitive(Class type)
  8. getBENameByPrimitiveClassName( String implementClassName)
  9. getDefaultPrimitiveValue(Class clazz)