Java 8 WeakHashMap - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 WeakHashMap class.

This code example shows how to use the following methods:
 
public class MenuWrapper implements Menu {
    private final android.view.Menu mNativeMenu;
 
    private final WeakHashMap<android.view.MenuItem, MenuItem> mNativeMap =
            new WeakHashMap<android.view.MenuItem, MenuItem>();
 
 
    public MenuWrapper(android.view.Menu nativeMenu) {
        mNativeMenu = nativeMenu;
    } 
 
    public android.view.Menu unwrap() {
        return mNativeMenu;
    } 
 
    private MenuItem addInternal(android.view.MenuItem nativeItem) {
        MenuItem item = new MenuItemWrapper(nativeItem);
        mNativeMap.put(nativeItem, item);
        return item;
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
public final class AnimatorProxy extends Animation {
    public static final boolean NEEDS_PROXY = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB;
 
    private static final WeakHashMap<View, AnimatorProxy> PROXIES =
            new WeakHashMap<View, AnimatorProxy>();
 
    public static AnimatorProxy wrap(View view) {
        AnimatorProxy proxy = PROXIES.get(view);
        if (proxy == null) {
            proxy = new AnimatorProxy(view);
            PROXIES.put(view, proxy);
        } 
        return proxy;
    } 
 
    private final WeakReference<View> mView;
 
    private float mAlpha = 1;
    private float mScaleX = 1;
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
public class MenuWrapper implements Menu {
    private final android.view.Menu mNativeMenu;
 
    private final WeakHashMap<android.view.MenuItem, MenuItem> mNativeMap =
            new WeakHashMap<android.view.MenuItem, MenuItem>();
 
 
    public MenuWrapper(android.view.Menu nativeMenu) {
        mNativeMenu = nativeMenu;
    } 
 
    public android.view.Menu unwrap() {
        return mNativeMenu;
    } 
 
    private MenuItem addInternal(android.view.MenuItem nativeItem) {
        MenuItem item = new MenuItemWrapper(nativeItem);
        mNativeMap.put(nativeItem, item);
        return item;
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
		implements IntroductionInterceptor { 
 
	/** 
	 * Hold weak references to keys as we don't want to interfere with garbage collection.. 
	 */ 
	private final Map<Object, Object> delegateMap = new WeakHashMap<Object, Object>();
 
	private Class<?> defaultImplType;
 
	private Class<?> interfaceType;
 
 
	public DelegatePerTargetObjectIntroductionInterceptor(Class<?> defaultImplType, Class<?> interfaceType) {
		this.defaultImplType = defaultImplType;
		this.interfaceType = interfaceType;
		// Create a new delegate now (but don't store it in the map). 
		// We do this for two reasons: 
		// 1) to fail early if there is a problem instantiating delegates 
		// 2) to populate the interface map once and once only 
		Object delegate = createNewDelegate(); 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get, put
            } 
        } 
 
        @Implementation 
        private static Map<String, Object> get(ContentResolver cr) {
            Map<String, Object> map = dataMap.get(cr);
            if (map == null) {
                map = new HashMap<String, Object>();
                dataMap.put(cr, map);
            } 
            return map;
        } 
    } 
 
    @Implements(Settings.System.class)
    public static class ShadowSystem extends SettingsImpl { 
    } 
 
    @Implements(Settings.Secure.class)
    public static class ShadowSecure extends SettingsImpl { 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:containsKey, get
     */ 
    private Drawable getActivityIconWithCache(ComponentName component) {
        // First check the icon cache 
        String componentIconKey = component.flattenToShortString();
        // Using containsKey() since we also store null values. 
        if (mOutsideDrawablesCache.containsKey(componentIconKey)) {
            Drawable.ConstantState cached = mOutsideDrawablesCache.get(componentIconKey);
            return cached == null ? null : cached.newDrawable(mProviderContext.getResources());
        } 
        // Then try the activity or application icon 
        Drawable drawable = getActivityIcon(component);
        // Stick it in the cache so we don't do this lookup again. 
        Drawable.ConstantState toCache = drawable == null ? null : drawable.getConstantState();
        mOutsideDrawablesCache.put(componentIconKey, toCache);
        return drawable;
    } 
 
    /** 
     * Gets the activity or application icon for an activity. 
     * 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	 * This is not strictly necessary for EJB3 Session Beans and Message-Driven 
	 * Beans, where interceptor instances get created per target bean instance. 
	 * It simply protects against future usage of the interceptor in a shared scenario. 
	 */ 
	private final Map<Object, BeanFactoryReference> beanFactoryReferences = 
			new WeakHashMap<Object, BeanFactoryReference>(); 
 
 
	/** 
	 * Autowire the target bean after construction as well as after passivation. 
	 * @param invocationContext the EJB3 invocation context 
	 */ 
	@PostConstruct 
	@PostActivate 
	public void autowireBean(InvocationContext invocationContext) { 
		doAutowireBean(invocationContext.getTarget()); 
		try { 
			invocationContext.proceed(); 
		} 
		catch (RuntimeException ex) { 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
public class MenuWrapper implements Menu {
    private final android.view.Menu mNativeMenu;
 
    private final WeakHashMap<android.view.MenuItem, MenuItem> mNativeMap =
            new WeakHashMap<android.view.MenuItem, MenuItem>();
 
 
    public MenuWrapper(android.view.Menu nativeMenu) {
        mNativeMenu = nativeMenu;
    } 
 
    public android.view.Menu unwrap() {
        return mNativeMenu;
    } 
 
    private MenuItem addInternal(android.view.MenuItem nativeItem) {
        MenuItem item = new MenuItemWrapper(nativeItem);
        mNativeMap.put(nativeItem, item);
        return item;
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:clear, get, put, size
	public IFile getFile() { 
		return file;
	} 
 
	public synchronized IControlFlowGraph getControlFlowGraph(IASTFunctionDefinition func) {
		IControlFlowGraph cfg = cfgmap.get(func);
		if (cfg != null)
			return cfg;
		cfg = CxxControlFlowGraph.build(func);
		// TODO(Alena Laskavaia): Change to LRU. 
		if (cfgmap.size() > 20) { // if too many function better drop the cash
			cfgmap.clear();
		} 
		cfgmap.put(func, cfg);
		return cfg;
	} 
 
	public synchronized ICodanCommentMap getCommentedNodeMap() { 
		return getCommentedNodeMap(tu);
	} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    } 
 
    private static final class ListenerWrapper implements 
            android.content.SharedPreferences.OnSharedPreferenceChangeListener {
        private static final Map<OnSharedPreferenceChangeListener, ListenerWrapper> sInstances =
                new WeakHashMap<OnSharedPreferenceChangeListener, ListenerWrapper>();
 
        private static synchronized ListenerWrapper obtain( 
                SharedPreferences prefs,
                OnSharedPreferenceChangeListener listener) {
            ListenerWrapper wrapper = sInstances.get(listener);
            if (wrapper == null) {
                sInstances.put(listener, wrapper = new ListenerWrapper(prefs, listener));
            } 
            return wrapper;
        } 
 
        private WeakReference<OnSharedPreferenceChangeListener> listenerRef;
        private SharedPreferences prefs;
 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Other Java 8 WeakHashMap Examples

24:	    MemoryCache memoryCache=new MemoryCache();
25:	    FileCache fileCache;
26:	    private Map imageViews=Collections.synchronizedMap(new WeakHashMap<ImageView, String>());
27:	    ExecutorService executorService; 
28:

Read More

See Code Examples for Java 8 WeakHashMap Methods: