Example usage for com.google.common.collect Sets newSetFromMap

List of usage examples for com.google.common.collect Sets newSetFromMap

Introduction

In this page you can find the example usage for com.google.common.collect Sets newSetFromMap.

Prototype

@Deprecated
public static <E> Set<E> newSetFromMap(Map<E, Boolean> map) 

Source Link

Document

Returns a set backed by the specified map.

Usage

From source file:org.apache.flex.compiler.internal.scopes.ASScopeCache.java

private Set<IASLanguageConstants.BuiltinType> getBuiltinTypeMap() {
    Set<IASLanguageConstants.BuiltinType> set = builtinTypeDependencyCache != null
            ? builtinTypeDependencyCache.get()
            : null;//from w  ww  .  j a va2  s  . c o  m
    if (set == null) {
        synchronized (this) {
            // Check again, in case another thread updated the set first
            set = builtinTypeDependencyCache != null ? builtinTypeDependencyCache.get() : null;
            if (set == null) {
                set = Sets.newSetFromMap(mapMaker.<IASLanguageConstants.BuiltinType, Boolean>makeMap());
                builtinTypeDependencyCache = new SoftReference<Set<IASLanguageConstants.BuiltinType>>(set);
            }
        }
    }
    return set;
}

From source file:org.trinity.foundation.api.render.binding.BinderImpl.java

protected void registerBinding(final Object dataContext, final Object view) {
    checkNotNull(dataContext);/*from  w w w.  j av a 2  s.c o m*/
    checkNotNull(view);

    final Object oldDataContext = this.dataContextValueByView.put(view, dataContext);
    if (oldDataContext != null) {
        final Set<Object> oldDataContextViews = this.viewsByDataContextValue.get(oldDataContext);
        if (oldDataContextViews != null) {
            oldDataContextViews.remove(view);
        }
    }
    Set<Object> dataContextViews = this.viewsByDataContextValue.get(dataContext);
    if (dataContextViews == null) {
        dataContextViews = Sets.newSetFromMap(new WeakHashMap<Object, Boolean>());
        this.viewsByDataContextValue.put(dataContext, dataContextViews);
    }
    dataContextViews.add(view);
}

From source file:org.apache.ambari.server.view.ViewRegistry.java

/**
 * Register the given listener to listen for events from the view identified by the given name and version.
 *
 * @param listener     the listener/*from   w w  w. jav a  2  s  .  c  om*/
 * @param viewName     the view name
 * @param viewVersion  the view version; null indicates all versions
 */
public synchronized void registerListener(Listener listener, String viewName, String viewVersion) {

    String name = viewVersion == null ? viewName : ViewEntity.getViewName(viewName, viewVersion);

    Set<Listener> listeners = this.listeners.get(name);

    if (listeners == null) {
        listeners = Sets.newSetFromMap(new ConcurrentHashMap<Listener, Boolean>());
        this.listeners.put(name, listeners);
    }

    listeners.add(listener);
}

From source file:silentium.gameserver.model.actor.L2Character.java

/**
 * @return a list of L2Character that attacked.
 *//*  w w  w.  j a v a 2s .co  m*/
public final Set<L2Character> getAttackByList() {
    if (_attackByList != null)
        return _attackByList;

    synchronized (this) {
        if (_attackByList == null)
            _attackByList = Sets.newSetFromMap(new WeakHashMap<L2Character, Boolean>());
    }
    return _attackByList;
}