api/src/main/java/io/sweers/barber/Barber.java
private static IBarbershop<Object> findBarbershopForClass(Class<?> cls) {
        IBarbershop<Object> barbershop = BARBERSHOPS.get(cls);
        if (barbershop != null) {
            if (debug) Log.d(TAG, "HIT: Cached in barbershop map.");
            return barbershop;
        }
        String clsName = cls.getName();
        if (clsName.startsWith(ANDROID_PREFIX) || clsName.startsWith(JAVA_PREFIX)) {
            if (debug) {
                Log.d(TAG, "MISS: Reached framework class. Abandoning search.");
            }
            return NO_OP;
        }
        //noinspection TryWithIdenticalCatches
        try {
            Class<?> barbershopClass = Class.forName(clsName + SUFFIX);
            //noinspection unchecked
            barbershop = (IBarbershop<Object>) barbershopClass.newInstance();
            if (debug) {
                Log.d(TAG, "HIT: Class loaded barbershop class.");
            }
        } catch (ClassNotFoundException e) {
            if (debug) {
                Log.d(TAG, "Not found. Trying superclass " + cls.getSuperclass().getName());
            }
            barbershop = findBarbershopForClass(cls.getSuperclass());
        } catch (InstantiationException e) {
            Log.e(TAG, e.getMessage());
        } catch (IllegalAccessException e) {
            Log.e(TAG, e.getMessage());
        }
        BARBERSHOPS.put(cls, barbershop);
        return barbershop;
    }
private static IBarbershop<Object> findBarbershopForClass(Class<?> cls) {
        IBarbershop<Object> barbershop = BARBERSHOPS.get(cls);
        if (barbershop != null) {
            if (debug) Log.d(TAG, "HIT: Cached in barbershop map.");
            return barbershop;
        }
        String clsName = cls.getName();
        if (clsName.startsWith(ANDROID_PREFIX) || clsName.startsWith(JAVA_PREFIX)) {
            if (debug) {
                Log.d(TAG, "MISS: Reached framework class. Abandoning search.");
            }
            return NO_OP;
        }
        //noinspection TryWithIdenticalCatches
        try {
            Class<?> barbershopClass = Class.forName(clsName + SUFFIX);
            //noinspection unchecked
            barbershop = (IBarbershop<Object>) barbershopClass.newInstance();
            if (debug) {
                Log.d(TAG, "HIT: Class loaded barbershop class.");
            }
        } catch (ClassNotFoundException e) {
            if (debug) {
                Log.d(TAG, "Not found. Trying superclass " + cls.getSuperclass().getName());
            }
            barbershop = findBarbershopForClass(cls.getSuperclass());
        } catch (InstantiationException e) {
            Log.e(TAG, e.getMessage());
        } catch (IllegalAccessException e) {
            Log.e(TAG, e.getMessage());
        }
        BARBERSHOPS.put(cls, barbershop);
        return barbershop;
    }
private static IBarbershop < Object > findBarbershopForClass ( Class < ? > cls ) { IBarbershop < Object > barbershop = BARBERSHOPS . get ( cls ) ; if ( barbershop != null ) { if ( debug ) Log . d ( TAG , "HIT: Cached in barbershop map." ) ; return barbershop ; } String clsName = cls . getName ( ) ; if ( clsName . startsWith ( ANDROID_PREFIX ) || clsName . startsWith ( JAVA_PREFIX ) ) { if ( debug ) { Log . d ( TAG , "MISS: Reached framework class. Abandoning search." ) ; } return NO_OP ; } //noinspection TryWithIdenticalCatches try { Class < ? > barbershopClass = Class . forName ( clsName + SUFFIX ) ; //noinspection unchecked barbershop = ( IBarbershop < Object > ) barbershopClass . newInstance ( ) ; if ( debug ) { Log . d ( TAG , "HIT: Class loaded barbershop class." ) ; } } catch ( ClassNotFoundException e ) { if ( debug ) { Log . d ( TAG , "Not found. Trying superclass " + cls . getSuperclass ( ) . getName ( ) ) ; } barbershop = findBarbershopForClass ( cls . getSuperclass ( ) ) ; } catch ( InstantiationException e ) { Log . e ( TAG , e . getMessage ( ) ) ; } catch ( IllegalAccessException e ) { Log . e ( TAG , e . getMessage ( ) ) ; } BARBERSHOPS . put ( cls , barbershop ) ; return barbershop ; }
Searches for $$Barbershop class for the given instance, cached for efficiency.

@param cls Source class to find a matching $$Barbershop class for
@return $$Barbershop class instance
Searches for $$Barbershop class for the given instance cached for efficiency .