Guava ImmutableBiMap - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava ImmutableBiMap class.

This code example shows how to use the following methods:containsKey
	 
	@Test public void testGetTokenDefMap_02() {
		ITokenDefProvider tokenDefProvider = get(ITokenDefProvider.class);
		ImmutableBiMap<Integer, String> tokens = ImmutableBiMap.copyOf(tokenDefProvider.getTokenDefMap());
		ImmutableBiMap<String,Integer> inverseTokens = tokens.inverse();
		assertTrue("'\n'", inverseTokens.containsKey("'\n'"));
		assertTrue("'\r'", inverseTokens.containsKey("'\r'"));
		assertTrue("RULE_ID", inverseTokens.containsKey("RULE_ID"));
		assertTrue("RULE_ANY_OTHER", inverseTokens.containsKey("RULE_ANY_OTHER"));
		assertTrue("RULE_WS", inverseTokens.containsKey("RULE_WS"));
	} 
	 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:inverse, get
        } 
        return action;
    } 
 
    static String post_1_4_action(String action) {
        return ACTION_NAMES.inverse().get(action);
    } 
 
    static String pre_1_4_Action(String action) {
        return ACTION_NAMES.get(action);
    } 
 
    private static ImmutableBiMap<String, String> createActionNamesMap() {
        ImmutableBiMap.Builder<String, String> builder = ImmutableBiMap.builder();
 
        addNodeAction(NodesRestartAction.NAME, "cluster/nodes/restart", builder);
        builder.put(NodesShutdownAction.NAME, "cluster/nodes/shutdown");
        builder.put(TransportNodesShutdownAction.SHUTDOWN_NODE_ACTION_NAME, "/cluster/nodes/shutdown/node");
 
        builder.put(DeleteRepositoryAction.NAME, "cluster/repository/delete");
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:get
   @Override 
   public K get() { 
      V uri = valueSupplier.get();
      // eagerly get all the values, so we can see which is default 
      Map<K, V> map = Maps.transformValues(supplier.get(), Suppliers.<V> supplierFunction());
      K region = ImmutableBiMap.copyOf(map).inverse().get(uri);
      if (region == null && !map.isEmpty()) {
         region = Iterables.get(map.keySet(), 0);
         logger.warn("failed to find key for value %s in %s; choosing first: %s", uri, map, region);
      } 
      return region;
   } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:inverse
        return readOnly;
    } 
 
    @NotNull 
    public ClassDescriptor convertReadOnlyToMutable(@NotNull ClassDescriptor readOnly) {
        ClassDescriptor mutable = mutableToReadOnlyMap.inverse().get(readOnly);
        if (mutable == null) {
            throw new IllegalArgumentException("Given class " + readOnly + " is not a read-only collection");
        } 
        return mutable;
    } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:get, size
    public void testImmutableBiMap( ObjectMapperTester<ImmutableBiMap<Integer, Boolean>> mapper ) {
        String json = mapper.write( ImmutableBiMap.of( 12, true, 4, false ) );
        assertEquals( "{\"12\":true,\"4\":false}", json );
 
        ImmutableBiMap<Integer, Boolean> map = mapper.read( json );
        assertEquals( 2, map.size() );
        assertEquals( Boolean.TRUE, map.get( 12 ) );
        assertEquals( Boolean.FALSE, map.get( 4 ) );
        assertEquals( map.get( 12 ), Boolean.TRUE );
        assertEquals( map.get( 4 ), Boolean.FALSE );
    } 
 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:values
    return (EmbeddableType<X>) embeddableTypes.get(cls);
  } 
 
  @Override 
  public Set<ManagedType<?>> getManagedTypes() {
    return managedTypes.values();
  } 
 
  @Override 
  public Set<EntityType<?>> getEntities() {
    return entityTypes.values(); 
  } 
 
  @Override 
  public Set<EmbeddableType<?>> getEmbeddables() {
    return embeddableTypes.values();
  } 
 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:containsKey, get
            .put(Short.TYPE, Short.class)
            .put(Void.TYPE, Void.class)
            .build();
     
    public static Class<?> boxedType(Class<?> type) {
        if (PRIMITIVE_TO_BOXED.containsKey(type))
            return PRIMITIVE_TO_BOXED.get(type);
        return type;
    } 
 
    /** sets the given element in an array to the indicated value; 
     * if the type is a primitive type, the appropriate primitive method is used 
     * <p> 
     * this is needed because arrays do not deal with autoboxing */ 
    public static void setInArray(Object target, int index, Object value, Class<?> type) {
        if (PRIMITIVE_TO_BOXED.containsKey(type)) {
            if (type.equals(Integer.TYPE))
                Array.setInt(target, index, (Integer)value);
            else if (type.equals(Long.TYPE))
                Array.setLong(target, index, (Long)value);
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:values
        return _pools.keySet();
    } 
 
    public ImmutableSet<CellAddressCore> getPoolCells()
    { 
        return _pools.values();
    } 
 
    @Override 
    public String toString()
    { 
        return super.toString() + " " + _pools;
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:values
    return hints; 
  } 
 
  @Override 
  public Set<Parameter<?>> getParameters() {
    return parameters.values(); 
  } 
 
  @Override 
  public Parameter<?> getParameter(String name) {
    return parameters.get(name);
  } 
 
  @Override 
  public <T> Parameter<T> getParameter(String name, Class<T> type) {
    Parameter<?> parameter = parameters.get(name);
    return verifyTypeCompatibility(parameter, type);
  } 
 
  @Override 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Guava ImmutableBiMap Methods: