Java Class Type Check isWrapperOfPrimitiveType(Class primitiveType, Class otherType)

Here you can find the source of isWrapperOfPrimitiveType(Class primitiveType, Class otherType)

Description

is Wrapper Of Primitive Type

License

Open Source License

Declaration

private static boolean isWrapperOfPrimitiveType(Class<?> primitiveType, Class<?> otherType) 

Method Source Code

//package com.java2s;
/*//  w  w w.j av  a  2 s. co m
 * Copyright (c) 2006-2012 Rog?rio Liesenfeld
 * This file is subject to the terms of the MIT license (see LICENSE.txt).
 */

import java.util.*;

public class Main {
    private static final Map<Class<?>, Class<?>> WRAPPER_TO_PRIMITIVE = new HashMap<Class<?>, Class<?>>() {
        {
            put(Boolean.class, boolean.class);
            put(Character.class, char.class);
            put(Byte.class, byte.class);
            put(Short.class, short.class);
            put(Integer.class, int.class);
            put(Float.class, float.class);
            put(Long.class, long.class);
            put(Double.class, double.class);
        }
    };

    private static boolean isWrapperOfPrimitiveType(Class<?> primitiveType, Class<?> otherType) {
        return primitiveType == WRAPPER_TO_PRIMITIVE.get(otherType);
    }

    public static boolean isWrapperOfPrimitiveType(Class<?> type) {
        return WRAPPER_TO_PRIMITIVE.containsKey(type);
    }
}

Related

  1. isSimpleType(Class clazz)
  2. isSupportedParameter(Class type)
  3. isTerminal(Class clazz)
  4. isTypeConvertible(Class srcType, Class destType)
  5. isUniformCollection(Collection c, Class e)
  6. isWrapperTypeOf(Class propertyType, Object propertyValue)