Get boxed class for primitive type

@param type
primitive class type
@return Object class type
17080
public static Class<?> getBoxedClass(Class<?> type) {
        if (type == boolean.class) {
            return Boolean.class;
        } else if (type == char.class) {
            return Character.class;
        } else if (type == byte.class) {
            return Byte.class;
        } else if (type == short.class) {
            return Short.class;
        } else if (type == int.class) {
            return Integer.class;
        } else if (type == long.class) {
            return Long.class;
        } else if (type == float.class) {
            return Float.class;
        } else if (type == double.class) {
            return Double.class;
        } else {
            return type;
        }
    }
745146
public static <T> T as(Object src, Class<T> type) {
        Class<?> t = type;
        while (t.isArray()) {
            t = t.getComponentType();
        }
        if (t == type) {
            // not an array at all
            return boxAs(src, type);
        } else {        
            if (t.isPrimitive()) {
                return deepUnboxAs(src, type);
            } else {
                return deepBoxAs(src, 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() );
    }
1160590
@Pure
	@SuppressWarnings({"checkstyle:returncount", "npathcomplexity"})
	public static Class<?> getOutboxingType(Class<?> type) {
		if (void.class.equals(type)) {
			return Void.class;
		}
		if (boolean.class.equals(type)) {
			return Boolean.class;
		}
		if (byte.class.equals(type)) {
			return Byte.class;
		}
		if (char.class.equals(type)) {
			return Character.class;
		}
		if (double.class.equals(type)) {
			return Double.class;
		}
		if (float.class.equals(type)) {
			return Float.class;
		}
		if (int.class.equals(type)) {
			return Integer.class;
		}
		if (long.class.equals(type)) {
			return Long.class;
		}
		if (short.class.equals(type)) {
			return Short.class;
		}
		return type;
	}
842760
public Type unboxedType(Type t) {
        for (int i=0; i<syms.boxedName.length; i++) {
            Name box = syms.boxedName[i];
            if (box != null &&
                asSuper(t, syms.enterClass(syms.java_base, box)) != null)
                return syms.typeOfTag[i];
        }
        return Type.noType;
    }
706689
public static Class<?> getPrimitiveClass(Type type) {
        switch (type.getDescriptor().charAt(0)) {
            case 'B':
                return byte.class;
            case 'C':
                return char.class;
            case 'D':
                return double.class;
            case 'F':
                return float.class;
            case 'I':
                return int.class;
            case 'J':
                return long.class;
            case 'S':
                return short.class;
            case 'V':
                return void.class;
            case 'Z':
                return boolean.class;

            default:
                throw new IllegalArgumentException("Unrecognized type [ " + type.getDescriptor() + " ]");
        }
    }
898868
public static Class<?> boxType( Class<?> primitiveType )
    {
        Class<?> c = wrapperMap.get( primitiveType );
        if ( c != null )
            return c;
        throw new InterpreterError(
            "Not a primitive type: "+ primitiveType );
    }
892030
@Override
    <T> Class<T> loadClass(final Class<T> superclassOrInterfaceType) {
        final Class<?> type = getType();
        if (!superclassOrInterfaceType.isAssignableFrom(type)) {
            throw new IllegalArgumentException(
                    "Primitive class " + baseType + " cannot be cast to " + superclassOrInterfaceType.getName());
        }
        @SuppressWarnings("unchecked")
        final Class<T> classT = (Class<T>) type;
        return classT;
    }
1177875
public static Class<?> getType( Object arg, boolean boxed ) {
        if ( null == arg || Primitive.NULL == arg )
            return null;
        if ( arg instanceof Primitive && !boxed )
            return ((Primitive) arg).getType();
       return Primitive.unwrap(arg).getClass();
    }
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;
        }
    }
1259137
public static FunctionalType unboxedUnaryOperator(TypeMirror type, Types types) {
    switch (type.getKind()) {
      case INT:
      case LONG:
      case DOUBLE:
        return primitiveUnaryOperator((PrimitiveType) type);

      case BOOLEAN:
      case BYTE:
      case CHAR:
      case SHORT:
      case FLOAT:
        return unaryOperator(types.boxedClass((PrimitiveType) type).asType());

      default:
        return unaryOperator(type);
    }
  }
1071591
public Type getType() {
        if (coordinates[0].length==1) return Type.POINT;
        else if (coordinates[0].length>2) return Type.POLYGON;
        else { //coordinates[0].length==2
            if (Float.isNaN(coordinates[0][1])) return Type.CIRCLE;
            else return Type.BOX;
        }
    }
503917
public static Primitive getDefaultValue( Class<?> type )
    {
        if ( type == null )
            return Primitive.NULL;
        if ( Boolean.TYPE == type || Boolean.class == type )
            return Primitive.FALSE;
        if ( Character.TYPE == type || Character.class == type )
            return Primitive.ZERO_CHAR;
        if ( Byte.TYPE == type || Byte.class == type )
            return Primitive.ZERO_BYTE;
        if ( Short.TYPE == type || Short.class == type )
            return Primitive.ZERO_SHORT;
        if ( Integer.TYPE == type || Integer.class == type )
            return Primitive.ZERO_INT;
        if ( Long.TYPE == type || Long.class == type )
            return Primitive.ZERO_LONG;
        if ( Float.TYPE == type || Float.class == type )
            return Primitive.ZERO_FLOAT;
        if ( Double.TYPE == type || Double.class == type )
            return Primitive.ZERO_DOUBLE;
        if ( BigInteger.class == type )
            return Primitive.ZERO_BIG_INTEGER;
        if ( BigDecimal.class == type )
            return Primitive.ZERO_BIG_DECIMAL;
        return Primitive.NULL;
    }
1276898
public static Class getTypeClass(Type type)
    {
        Class typeClassClass = null;

        if (type instanceof Class) {
            typeClassClass = (Class) type;
        } else if (type instanceof ParameterizedType) {
            typeClassClass = (Class) ((ParameterizedType) type).getRawType();
        } else if (type instanceof GenericArrayType) {
            Class<?> arrrayParameter = getTypeClass(((GenericArrayType) type).getGenericComponentType());
            if (arrrayParameter != null) {
                typeClassClass = Array.newInstance(arrrayParameter, 0).getClass();
            }
        }

        return typeClassClass;
    }
899853
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();
			if (!(rawType instanceof Class)) {
				String message = MessageFormat.format("Expected a Class, but <{0}> is of type {1}", type, type.getClass()
						.getName());
				throw new IllegalArgumentException(message);
			}
			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());
		}
	}
1052710
protected synchronized HierarchicalType getDataType(String type) {
        HierarchicalType dataType = typeInstances.get(type);
        //todo: are there still cases where type can be null?
        if (dataType == null) {
            dataType = createDataType(type);
            typeInstances.put(type, dataType);
        }
        return dataType;
    }
465295
public static Class<?> getObjectClassOfPrimitve(Class<?> primitive) {
        Class<?> objectClass = PRIMITIVE_TO_WRAPPER.get(primitive);
        if (objectClass != null) {
            return objectClass;
        }

        return primitive;
    }