Java Code Examples for com.google.common.collect.ImmutableBiMap#get()

The following examples show how to use com.google.common.collect.ImmutableBiMap#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
public static List<ProtocolEntry> createMdsalProtocols(final Bridge bridge) {
    Set<String> protocols = null;
    try {
        protocols = bridge.getProtocolsColumn().getData();
    } catch (SchemaVersionMismatchException e) {
        schemaMismatchLog("protocols", "Bridge", e);
    }
    List<ProtocolEntry> protocolList = new ArrayList<>();
    if (protocols != null && !protocols.isEmpty()) {
        ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper =
                SouthboundConstants.OVSDB_PROTOCOL_MAP.inverse();
        for (String protocol : protocols) {
            if (protocol != null) {
                final Class<? extends OvsdbBridgeProtocolBase> mapped = mapper.get(protocol);
                if (mapped != null) {
                    protocolList.add(new ProtocolEntryBuilder().setProtocol(mapped).build());
                }
            }
        }
    }
    return protocolList;
}
 
Example 2
Source File: SouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Return the MD-SAL QoS type class corresponding to the QoS type {@link Qos}.
 *
 * @param type the QoS type to match {@link String}
 * @return class matching the input QoS type {@link QosTypeBase}
 */
public static  Class<? extends QosTypeBase> createQosType(final String type) {
    Preconditions.checkNotNull(type);
    if (type.isEmpty()) {
        LOG.info("QoS type not supplied");
        return QosTypeBase.class;
    } else {
        ImmutableBiMap<String, Class<? extends QosTypeBase>> mapper =
                SouthboundConstants.QOS_TYPE_MAP.inverse();
        if (mapper.get(type) == null) {
            LOG.info("QoS type not found in model: {}", type);
            return QosTypeBase.class;
        } else {
            return mapper.get(type);
        }
    }
}
 
Example 3
Source File: AccessibilityCheckResultBaseUtils.java    From Accessibility-Test-Framework-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an alias for the given object, if it has one.
 *
 * <p>This supports aliasing in both directions. For example, a Matcher that specifies a new check
 * class can match a result with an old check class. Or a Matcher that specifies an old check
 * class can match a result with a new check class.
 */
private static @Nullable Object getAlias(Object obj, @Nullable ImmutableBiMap<?, ?> aliases) {
  if (aliases == null) {
    return null;
  }
  Object alias = aliases.get(obj);
  return (alias != null) ? alias : aliases.inverse().get(obj);
}
 
Example 4
Source File: HwvtepSouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
public static Class<? extends EncapsulationTypeBase> createEncapsulationType(String type) {
    Preconditions.checkNotNull(type);
    if (type.isEmpty()) {
        return EncapsulationTypeVxlanOverIpv4.class;
    } else {
        ImmutableBiMap<String, Class<? extends EncapsulationTypeBase>> mapper =
                HwvtepSouthboundConstants.ENCAPS_TYPE_MAP.inverse();
        return mapper.get(type);
    }
}
 
Example 5
Source File: FactoryDescriptor.java    From auto with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a set of deduplicated {@link FactoryMethodDescriptor}s from the set of original
 * descriptors and the bi-map of duplicate descriptors.
 *
 * <p>Modifies the duplicate {@link FactoryMethodDescriptor}s such that they are overriding and
 * reflect properties from the {@link ImplementationMethodDescriptor} they are implementing.
 */
private static ImmutableSet<FactoryMethodDescriptor> getDeduplicatedMethodDescriptors(
    ImmutableSet<FactoryMethodDescriptor> methodDescriptors,
    ImmutableBiMap<FactoryMethodDescriptor, ImplementationMethodDescriptor>
        duplicateMethodDescriptors) {

  ImmutableSet.Builder<FactoryMethodDescriptor> deduplicatedMethodDescriptors =
      ImmutableSet.builder();

  for (FactoryMethodDescriptor methodDescriptor : methodDescriptors) {
    ImplementationMethodDescriptor duplicateMethodDescriptor =
        duplicateMethodDescriptors.get(methodDescriptor);

    FactoryMethodDescriptor newMethodDescriptor =
       (duplicateMethodDescriptor != null)
            ? methodDescriptor
                .toBuilder()
                .overridingMethod(true)
                .publicMethod(duplicateMethodDescriptor.publicMethod())
                .returnType(duplicateMethodDescriptor.returnType())
                .build()
            : methodDescriptor;
    deduplicatedMethodDescriptors.add(newMethodDescriptor);
  }

  return deduplicatedMethodDescriptors.build();
}
 
Example 6
Source File: SouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 4 votes vote down vote up
public static String createOvsdbInterfaceType(final Class<? extends InterfaceTypeBase> mdsaltype) {
    Preconditions.checkNotNull(mdsaltype);
    ImmutableBiMap<Class<? extends InterfaceTypeBase>, String> mapper =
            SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP.inverse();
    return mapper.get(mdsaltype);
}