Here you can find the source of primitiveToWrapper(Class cls)
Converts the specified primitive Class object to its corresponding wrapper Class object.
Parameter | Description |
---|---|
cls | the class to convert, may be null |
cls
or cls
if cls
is not a primitive. null
if null input.
public static Class primitiveToWrapper(Class cls)
//package com.java2s; /*//from www . ja v a 2s.c o m * Copyright (c) 2007-2016 AREasy Runtime * * This library, AREasy Runtime and API for BMC Remedy AR System, is free software ("Licensed 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 2.1 of the License, * or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * including but not limited to, the implied warranty of MERCHANTABILITY, NONINFRINGEMENT, * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. */ import java.util.*; public class Main { /** * Maps primitive <code>Class</code>es to their corresponding wrapper <code>Class</code>. */ private static Map primitiveWrapperMap = new HashMap(); /** * <p>Converts the specified primitive Class object to its corresponding * wrapper Class object.</p> * * @param cls the class to convert, may be null * @return the wrapper class for <code>cls</code> or <code>cls</code> if * <code>cls</code> is not a primitive. <code>null</code> if null input. */ public static Class primitiveToWrapper(Class cls) { Class convertedClass = cls; if (cls != null && cls.isPrimitive()) convertedClass = (Class) primitiveWrapperMap.get(cls); return convertedClass; } }