Java Reflection Assignable isAssignable(Class lhsType, Class rhsType)

Here you can find the source of isAssignable(Class lhsType, Class rhsType)

Description

is Assignable

License

Apache License

Declaration

public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.HashMap;
import java.util.Map;

public class Main {
    /**/*from w ww.  j a v a  2s .  co m*/
     * Map with primitive wrapper type as key and corresponding primitive
     * type as value, for example: Integer.class -> int.class.
     */
    private static final Map<Class<?>, Class<?>> primitiveWrapperTypeMap = new HashMap<Class<?>, Class<?>>(8);

    public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) {
        return (lhsType.isAssignableFrom(rhsType) || lhsType.equals(primitiveWrapperTypeMap.get(rhsType)));
    }
}

Related

  1. isAssignable(Class clazz, Class toClass)
  2. isAssignable(Class lhsType, Class rhsType)
  3. isAssignable(Class cls, final Class toClass)
  4. isAssignable(Class lhsType, Class rhsType)
  5. isAssignable(Class lhsType, Class rhsType)
  6. isAssignable(final Class from, final Class to)
  7. isAssignableFrom(Class class1, Class class2)
  8. isAssignableFrom(Class to, Class from)