Code example for WeakHashMap

0
 
    /** 
     * This class gets twice as many providers as necessary to do its job, look into optimizations in the future if this is a bottleneck 
     */ 
    public static class ViewMembersInjector<T> implements MembersInjector<T> { 
        protected static WeakHashMap<Object,ArrayList<ViewMembersInjector<?>>> viewMembersInjectors = new WeakHashMap<Object, ArrayList<ViewMembersInjector<?>>>();
 
        protected Field field;
        protected Annotation annotation;
        protected WeakReference<T> instanceRef;
        protected Provider fragmentManagerProvider;
        protected Provider<Activity> activityProvider;
         
 
        public ViewMembersInjector(Field field, Annotation annotation, TypeEncounter<T> typeEncounter ) {
            this.field = field;
            this.annotation = annotation;
            this.activityProvider = typeEncounter.getProvider(Activity.class);
 
            if( fragmentManagerClass!=null )
                this.fragmentManagerProvider = typeEncounter.getProvider(fragmentManagerClass);