Class Reflection.AssignabilityChecker

  • Enclosing class:
    Reflection

    protected static class Reflection.AssignabilityChecker
    extends Object
    • Field Detail

      • classAssignabilityMap

        protected final ConcurrentHashMap<Class<?>,​ConcurrentHashMap<Class<?>,​Boolean>> classAssignabilityMap
        This map stores for a class name, which other class names have been found to be assignable to it.

        In more detail:

        • For a given class name (outer), you get back a map.
        • Each entry is a tuple of another class name (inner) and a boolean that states whether or not you can assign the inner class to the outer class.
        TODO: This map can grow quite fast, theoretically up to n^2; n = # of classes
    • Constructor Detail

      • AssignabilityChecker

        public AssignabilityChecker()
    • Method Detail

      • isAssignableFrom

        public boolean isAssignableFrom​(Class<?> clazz,
                                        Class<?> other)
        Checks if the 'clazz' class is assignable from the 'other' class.

        Identical to clazz.isAssignableFrom(other), but might use caching to speed up resolution. This is useful if Java 5 (or earlier) is used, as these use a much slower implementation than Java 6+.

        TODO: Disable caching as soon as Java 5 has been deprecated for Jenkins

        Parameters:
        clazz - the class to which 'other' must be assignable (left-hand value)
        other - the class which must be assignable to 'clazz' (right-hand value)
        Returns:
        true, if 'other' is a subtype of 'clazz.