Here you can find the source of sanitizePrimitives(Class> clazz)
This method checks if the input clazz can be converted to a primitive type.
Parameter | Description |
---|---|
clazz | The class to sanitize. |
public static Class<?> sanitizePrimitives(Class<?> clazz)
//package com.java2s; // The MIT License(MIT) public class Main { /**//from ww w .jav a2s. c o m * <p> * This method checks if the input {@code clazz} can be converted to a primitive type. * </p> * * <p> * For example, if the input {@code clazz} is an {@code Integer}, it will convert it to an {@code int}. * </p> * * @param clazz The class to sanitize. * @return The primitive version of the input class if it exists. */ public static Class<?> sanitizePrimitives(Class<?> clazz) { if (clazz == Byte.class) { return byte.class; } if (clazz == Short.class) { return short.class; } if (clazz == Integer.class) { return int.class; } if (clazz == Long.class) { return long.class; } if (clazz == Float.class) { return float.class; } if (clazz == Double.class) { return double.class; } if (clazz == Character.class) { return char.class; } if (clazz == Boolean.class) { return boolean.class; } return clazz; } }