If this specified class represents a primitive type (int, float, etc.)
then it is translated into its wrapper type (Integer, Float, etc.). If
the passed class is not a primitive then it is just returned.

@param primitive class
@return class
439001
private static Class<?> translateFromPrimitive(Class<?> primitive) {
        if (!primitive.isPrimitive()) {
            return primitive;
        }

        if (Boolean.TYPE.equals(primitive)) {
            return Boolean.class;
        }
        if (Character.TYPE.equals(primitive)) {
            return Character.class;
        }
        if (Byte.TYPE.equals(primitive)) {
            return Byte.class;
        }
        if (Short.TYPE.equals(primitive)) {
            return Short.class;
        }
        if (Integer.TYPE.equals(primitive)) {
            return Integer.class;
        }
        if (Long.TYPE.equals(primitive)) {
            return Long.class;
        }
        if (Float.TYPE.equals(primitive)) {
            return Float.class;
        }
        if (Double.TYPE.equals(primitive)) {
            return Double.class;
        }

        throw new RuntimeException("Error translating type:" + primitive);
    }
1079397
private static Class <?> type2class(Type type){
		if(type instanceof Class <?>){
			return (Class <?>) type;	//base case
		}else if(type instanceof ParameterizedType){
			return type2class( ((ParameterizedType) type).getRawType() );
		}else if(type instanceof TypeVariable<?>){
			return type2class( ((TypeVariable<?>) type).getBounds()[0] );
		}else if(type instanceof WildcardType){
			return type2class( ((WildcardType) type).getUpperBounds()[0] );
		}else{
			throw new IllegalArgumentException("Cannot convert type to class: " + type);
		}
	}
1339083
public static Object convertPrimitive(Object object)
    {
        if (object == null)
        {
            return object;
        }
        Class<?> clazz = object.getClass();
        if (clazz.isPrimitive())
        {
            if (boolean.class.equals(clazz))
            {
                Boolean b = (Boolean) object;
                return b;
            }
            if (byte.class.equals(clazz))
            {
                Byte b = (Byte) object;
                return b;
            }
            if (char.class.equals(clazz))
            {
                Character c = (Character) object;
                return c;
            }
            if (short.class.equals(clazz))
            {
                Short s = (Short) object;
                return s;
            }
            if (int.class.equals(clazz))
            {
                Integer i = (Integer) object;
                return i;
            }
            if (long.class.equals(clazz))
            {
                Long l = (Long) object;
                return l;
            }
            if (float.class.equals(clazz))
            {
                Float f  = (Float) object;
                return f;
            }
            if (double.class.equals(clazz))
            {
                Double d  = (Double) object;
                return d;
            }
            throw new IllegalArgumentException("Unknown primitive type'" + clazz);
        }
        return object;
    }
843291
Class<?> classOfPrimitiveArrayFor(String primitiveType) {
        return ClassUtils.arrayTypeForPrimitive(primitiveType)
                    .orElseThrow(() -> new IllegalArgumentException("Unsupported primitive type " + primitiveType));
    }
1370067
public Type toPrimitive() {
        if (mPrimitive) {
            return this;
        }
        else {
            Class<?> primitive = convertToPrimitive(mObjectClass);
            if (primitive.isPrimitive()) { return new Type(primitive); }
            else { return new Type(mGenericType, primitive); }
        }
    }
677114
protected PrimitiveTypeConfiguration primitiveType( Class type ) {
        if ( !type.isPrimitive() ) {
            throw new IllegalArgumentException( "Type " + type + " is not a primitive. Call type(Class) instead" );
        }
        return new PrimitiveTypeConfiguration( type );
    }
686812
public Class<?> getType()
    {
        if ( this == Primitive.VOID )
            return Void.TYPE;

        // NULL return null as type... we currently use null type to indicate
        // loose typing throughout bsh.
        if ( this == Primitive.NULL )
            return null;

        return unboxType( value.getClass() );
    }
1115096
public static Class<?> wrapper(Class<?> type) {
        if (type == null) {
            return null;
        }
        else if (type.isPrimitive()) {
            if (boolean.class == type) {
                return Boolean.class;
            }
            else if (int.class == type) {
                return Integer.class;
            }
            else if (long.class == type) {
                return Long.class;
            }
            else if (short.class == type) {
                return Short.class;
            }
            else if (byte.class == type) {
                return Byte.class;
            }
            else if (double.class == type) {
                return Double.class;
            }
            else if (float.class == type) {
                return Float.class;
            }
            else if (char.class == type) {
                return Character.class;
            }
            else if (void.class == type) {
                return Void.class;
            }
        }

        return type;
    }
498418
public static Class<?> getPrimitiveType(Class<?> wrapperType) {
        if (Boolean.class.equals(wrapperType)) {
            return Boolean.TYPE;
        } else if (Byte.class.equals(wrapperType)) {
            return Byte.TYPE;
        } else if (Character.class.equals(wrapperType)) {
            return Character.TYPE;
        } else if (Short.class.equals(wrapperType)) {
            return Short.TYPE;
        } else if (Integer.class.equals(wrapperType)) {
            return Integer.TYPE;
        } else if (Long.class.equals(wrapperType)) {
            return Long.TYPE;
        } else if (Float.class.equals(wrapperType)) {
            return Float.TYPE;
        } else if (Double.class.equals(wrapperType)) {
            return Double.TYPE;
        } else {
            return null;
        }
    }
933675
@SuppressWarnings("unckecked")
    public static Class<?> getRawType(Type type) {
        if (type instanceof Class<?>) {
            // type is a normal class.
            return (Class<?>) type;

        } else if (type instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) type;

            // I'm not exactly sure why getRawType() returns Type instead of Class.
            // Neal isn't either but suspects some pathological case related
            // to nested classes exists.
            Type rawType = parameterizedType.getRawType();
            checkArgument(rawType instanceof Class,
                    "Expected a Class, but <%s> is of type %s", type, type.getClass().getName());
            //noinspection ConstantConditions
            return (Class<?>) rawType;

        } else if (type instanceof GenericArrayType) {
            Type componentType = ((GenericArrayType) type).getGenericComponentType();
            return Array.newInstance(getRawType(componentType), 0).getClass();

        } else if (type instanceof TypeVariable) {
            // we could use the variable's bounds, but that'll won't work if there are multiple.
            // having a raw type that's more general than necessary is okay
            return Object.class;

        } else {
            throw new IllegalArgumentException("Expected a Class, ParameterizedType, or "
                    + "GenericArrayType, but <" + type + "> is of type " + type.getClass().getName());
        }
    }
1188573
static boolean isPrimitiveNumberClass(Class pClass) {
        return
                pClass == Byte.class ||
                        pClass == Byte.TYPE ||
                        pClass == Short.class ||
                        pClass == Short.TYPE ||
                        pClass == Integer.class ||
                        pClass == Integer.TYPE ||
                        pClass == Long.class ||
                        pClass == Long.TYPE ||
                        pClass == Float.class ||
                        pClass == Float.TYPE ||
                        pClass == Double.class ||
                        pClass == Double.TYPE;
    }
1236333
def return_primitive(fn):
    
    @wraps(fn)
    def wrapped_fn(x):
        if isinstance(x, PRIMITIVE_TYPES):
            return x
        return fn(x)
    return wrapped_fn
221462
public static Class getPrimitiveType(Class type) {
        if (type == int.class || type == Integer.class) {
            return int.class;
        } else if (type == long.class || type == Long.class) {
            return long.class;
        } else if (type == short.class || type == Short.class) {
            return short.class;
        } else if (type == double.class || type == Double.class) {
            return double.class;
        } else if (type == float.class || type == Float.class) {
            return float.class;
        } else if (type == char.class || type == Character.class) {
            return char.class;
        } else if (type == byte.class || type == Byte.class) {
            return byte.class;
        } else if (type == boolean.class || type == Boolean.class) {
            return boolean.class;
        }
        throw new IllegalArgumentException("Type '" + type + "' can not be converted to primitive type.");
    }
1114488
@Override
    public final Class<T> returnedClass() {
        @SuppressWarnings("unchecked")Class<T> result = (Class<T>) TypeHelper.getTypeArguments(AbstractColumnMapper.class, getClass()).get(0);
        return result;
    }
823316
public static Class unwrapType(Class pType) {
        if (pType == Boolean.class) {
            return Boolean.TYPE;
        }
        else if (pType == Byte.class) {
            return Byte.TYPE;
        }
        else if (pType == Character.class) {
            return Character.TYPE;
        }
        else if (pType == Double.class) {
            return Double.TYPE;
        }
        else if (pType == Float.class) {
            return Float.TYPE;
        }
        else if (pType == Integer.class) {
            return Integer.TYPE;
        }
        else if (pType == Long.class) {
            return Long.TYPE;
        }
        else if (pType == Short.class) {
            return Short.TYPE;
        }

        throw new IllegalArgumentException("Not a primitive wrapper: " + pType);
    }
1135425
public static final Class<?> getPrimitiveClass(Class<?> clazz)
    {
        Class<?> retValue = clazz;
        if (clazz == java.lang.Long.class)
        {
            retValue = Long.TYPE;
        } else if (clazz == java.lang.Integer.class)
        {
            retValue = Integer.TYPE;
        } else if (clazz == java.lang.Boolean.class)
        {
            retValue = Boolean.TYPE;
        } else if (clazz == java.lang.Short.class)
        {
            retValue = Short.TYPE;
        } else if (clazz == java.lang.Byte.class)
        {
            retValue = Byte.TYPE;
        } else if (clazz == java.lang.Character.class)
        {
            retValue = Character.TYPE;
        } else if (clazz == java.lang.Double.class)
        {
            retValue = Double.TYPE;
        } else if (clazz == java.lang.Float.class)
        {
            retValue = Float.TYPE;
        }
        return retValue;
    }
1140609
public static boolean isPrimitiveType(Type type) {
	String className = type.getClassName();
	if (className.indexOf('.') != -1) return false;

	if ("boolean".equals(className)) return true;
	if ("short".equals(className)) return true;
	if ("float".equals(className)) return true;
	if ("long".equals(className)) return true;
	if ("double".equals(className)) return true;
	if ("char".equals(className)) return true;
	if ("int".equals(className)) return true;
	if ("byte".equals(className)) return true;

	return false;
    }