Example usage for com.google.common.collect ImmutableBiMap get

List of usage examples for com.google.common.collect ImmutableBiMap get

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableBiMap get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:org.opendaylight.netvirt.openstack.netvirt.MdsalHelper.java

public static String createOvsdbInterfaceType(Class<? extends InterfaceTypeBase> mdsaltype) {
    Preconditions.checkNotNull(mdsaltype);
    ImmutableBiMap<Class<? extends InterfaceTypeBase>, String> mapper = OVSDB_INTERFACE_TYPE_MAP.inverse();
    return mapper.get(mdsaltype);
}

From source file:org.opendaylight.ovsdb.openstack.netvirt.it.SouthboundMapper.java

public static String createOvsdbInterfaceType(Class<? extends InterfaceTypeBase> mdsaltype) {
    Preconditions.checkNotNull(mdsaltype);
    ImmutableBiMap<Class<? extends InterfaceTypeBase>, String> mapper = SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP
            .inverse();//  ww  w. jav a2  s  .c om
    return mapper.get(mdsaltype);
}

From source file:org.opendaylight.ovsdb.openstack.netvirt.it.SouthboundMapper.java

public static Class<? extends DatapathTypeBase> createDatapathType(String type) {
    Preconditions.checkNotNull(type);//from   w  w  w .  j  av a 2 s. c o m
    if (type.isEmpty()) {
        return DatapathTypeSystem.class;
    } else {
        ImmutableBiMap<String, Class<? extends DatapathTypeBase>> mapper = SouthboundConstants.DATAPATH_TYPE_MAP
                .inverse();
        return mapper.get(type);
    }
}

From source file:org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper.java

public static Class<? extends EncapsulationTypeBase> createEncapsulationType(String type) {
    Preconditions.checkNotNull(type);/* w  ww. j av  a  2 s  . com*/
    if (type.isEmpty()) {
        return EncapsulationTypeVxlanOverIpv4.class;
    } else {
        ImmutableBiMap<String, Class<? extends EncapsulationTypeBase>> mapper = HwvtepSouthboundConstants.ENCAPS_TYPE_MAP
                .inverse();
        return mapper.get(type);
    }
}

From source file:org.opendaylight.ovsdb.southbound.SouthboundMapper.java

public static List<ProtocolEntry> createMdsalProtocols(Bridge bridge) {
    Set<String> protocols = null;
    try {//from   w w  w .  ja  v  a 2  s  .co  m
        protocols = bridge.getProtocolsColumn().getData();
    } catch (SchemaVersionMismatchException e) {
        LOG.warn("protocols not supported by this version of ovsdb", e);
    }
    List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
    if (protocols != null && protocols.size() > 0) {
        ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper = SouthboundConstants.OVSDB_PROTOCOL_MAP
                .inverse();
        for (String protocol : protocols) {
            if (protocol != null && mapper.get(protocol) != null) {
                protocolList.add(new ProtocolEntryBuilder()
                        .setProtocol((Class<? extends OvsdbBridgeProtocolBase>) mapper.get(protocol)).build());
            }
        }
    }
    return protocolList;
}

From source file:org.opendaylight.unimgr.utils.OvsdbUtils.java

/**
 * Utility function used to create a protocol entry when creating a bridge node.
 * @return A List of protocol entry/*from  w w  w.  j a  v a 2 s .c  o  m*/
 */
public static List<ProtocolEntry> createMdsalProtocols() {
    final List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
    final ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper = SouthboundConstants.OVSDB_PROTOCOL_MAP
            .inverse();
    protocolList.add(new ProtocolEntryBuilder()
            .setProtocol((Class<? extends OvsdbBridgeProtocolBase>) mapper.get("OpenFlow13")).build());
    return protocolList;
}

From source file:net.tsquery.data.hbase.IDMap.java

public ID getTagID(String tag) throws IOException, IDNotFoundException {
    ImmutableBiMap<String, ID> tagsMap = syncTagsLoader.get();
    ID tagID = tagsMap.get(tag);
    if (tagID == null) {
        throw new IDNotFoundException("tag '" + tag + "' not found");
    }// ww w.  j ava 2s  .  com
    return tagID;
}

From source file:net.tsquery.data.hbase.IDMap.java

public ID getMetricID(String metric) throws IOException, IDNotFoundException {
    ImmutableBiMap<String, ID> metricsMap = syncMetricsLoader.get();
    ID metricID = metricsMap.get(metric);
    if (metricID == null) {
        throw new IDNotFoundException("metric '" + metric + "' not found");
    }/* www  . j ava  2 s . co m*/
    return metricID;
}

From source file:net.tsquery.data.hbase.IDMap.java

public ID getTagValueID(String tagValue) throws IOException, IDNotFoundException {
    ImmutableBiMap<String, ID> tagValuesMap = syncTagValuesLoader.get();
    ID tagValueID = tagValuesMap.get(tagValue);
    if (tagValueID == null) {
        throw new IDNotFoundException("tag value '" + tagValue + "' not found");
    }/*  w w w . j  a va  2  s . com*/
    return tagValueID;
}

From source file:org.opendaylight.neutron.transcriber.NeutronLoadBalancerListenerInterface.java

@Override
protected Listener toMd(NeutronLoadBalancerListener listener) {
    final ListenerBuilder listenerBuilder = new ListenerBuilder();
    toMdBaseAttributes(listener, listenerBuilder);
    listenerBuilder.setAdminStateUp(listener.getLoadBalancerListenerAdminStateIsUp());
    if (listener.getNeutronLoadBalancerListenerConnectionLimit() != null) {
        listenerBuilder.setConnectionLimit(listener.getNeutronLoadBalancerListenerConnectionLimit());
    }/*from  w w  w .  j a  va  2 s . c  o  m*/
    if (listener.getNeutronLoadBalancerListenerDefaultPoolID() != null) {
        listenerBuilder.setDefaultPoolId(toUuid(listener.getNeutronLoadBalancerListenerDefaultPoolID()));
    }
    if (listener.getNeutronLoadBalancerListenerLoadBalancerIDs() != null) {
        final List<Uuid> listLoadBalancers = new ArrayList<Uuid>();
        for (final NeutronID neutronId : listener.getNeutronLoadBalancerListenerLoadBalancerIDs()) {
            listLoadBalancers.add(toUuid(neutronId.getID()));
        }
        listenerBuilder.setLoadbalancers(listLoadBalancers);
    }
    if (listener.getNeutronLoadBalancerListenerProtocol() != null) {
        final ImmutableBiMap<String, Class<? extends ProtocolBase>> mapper = PROTOCOL_MAP.inverse();
        Class<? extends ProtocolBase> protocol = mapper.get(listener.getNeutronLoadBalancerListenerProtocol());
        if (protocol != null) {
            listenerBuilder.setProtocol(protocol);
        } else {
            throw new BadRequestException(
                    "Protocol {" + listener.getNeutronLoadBalancerListenerProtocol() + "} is not supported");
        }
    }
    if (listener.getNeutronLoadBalancerListenerProtocolPort() != null) {
        listenerBuilder.setProtocolPort(Integer.valueOf(listener.getNeutronLoadBalancerListenerProtocolPort()));
    }
    return listenerBuilder.build();
}