Example usage for com.google.common.collect ClassToInstanceMap keySet

List of usage examples for com.google.common.collect ClassToInstanceMap keySet

Introduction

In this page you can find the example usage for com.google.common.collect ClassToInstanceMap keySet.

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:org.opendaylight.didm.mininet.DidmMininetProviderImpl.java

/***
  * Registers all drivers for a devicetype
  * @param deviceType The devicetype//w  w  w.j  av  a 2  s  . com
  * @param path The node the drivers apply to
  * @return List of successful routed RPC registrations
  */
private List<BindingAwareBroker.RoutedRpcRegistration<RpcService>> registerDrivers(String deviceType,
        InstanceIdentifier<Node> path) {
    LOG.info("onNodeIdentified!");

    List<BindingAwareBroker.RoutedRpcRegistration<RpcService>> list = new ArrayList<>();

    // get all the drivers to be registered as routed RPCs
    ClassToInstanceMap<RpcService> map = getDrivers(deviceType);

    Set<Class<? extends RpcService>> driverTypes = map.keySet();

    for (Class<? extends RpcService> clazz : driverTypes) {
        BindingAwareBroker.RoutedRpcRegistration<RpcService> registration = registerRpcService(clazz,
                map.getInstance(clazz), path);
        if (registration != null) {
            list.add(registration);
        } else {
            // TODO: do we need a onRegistrationFailed() extension?
        }
    }
    return list;
}

From source file:com.google.devtools.build.lib.analysis.config.BuildConfiguration.java

/**
 * Returns a copy of this configuration only including the given fragments (which the current
 * configuration is assumed to have)./*from   w  w w.  j  a  va 2  s .  c om*/
 */
public BuildConfiguration clone(Set<Class<? extends BuildConfiguration.Fragment>> fragmentClasses,
        RuleClassProvider ruleClassProvider) {

    ClassToInstanceMap<Fragment> fragmentsMap = MutableClassToInstanceMap.create();
    for (Fragment fragment : fragments.values()) {
        if (fragmentClasses.contains(fragment.getClass())) {
            fragmentsMap.put(fragment.getClass(), fragment);
        }
    }
    BuildOptions options = buildOptions.trim(getOptionsClasses(fragmentsMap.keySet(), ruleClassProvider));
    BuildConfiguration newConfig = new BuildConfiguration(directories, fragmentsMap, options, !actionsEnabled);
    newConfig.setConfigurationTransitions(this.transitions);
    return newConfig;
}