Guava ImmutableMap - 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 ImmutableMap 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
This code example shows how to use the following methods:get
     * 
     * @param name The given name 
     * @return The associated stream 
     */ 
    public static Stream stream(String name) {
        return STREAMS.get(name);
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:get
    public RiversTypesRegistry(ImmutableMap<String, Class<? extends Module>> riverTypes) { 
        this.riverTypes = riverTypes; 
    } 
 
    public Class<? extends Module> type(String type) { 
        return riverTypes.get(type); 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:containsKey, get
    public String getType() {
        return type;
    } 
 
    public boolean hasProperty(String name) {
        return properties.containsKey(name);
    } 
 
    public String getProperty(String name) {
        return properties.get(name);
    } 
 
    public Map<String, String> getProperties() {
        return properties;
    } 
 
    public String getProperty(String name, String defaultValue) {
        if (hasProperty(name)) {
            return properties.get(name);
        } else { 

6
CodeRank
This code example shows how to use the following methods:values
     * Returns the list of pre-defined SimilarityProvider Factories 
     * 
     * @return Pre-defined SimilarityProvider Factories 
     */ 
    public static ImmutableCollection<PreBuiltSimilarityProvider.Factory> listFactories() { 
        return PRE_BUILT_SIMILARITIES.values(); 
    } 
} 
6
CodeRank
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
This code example shows how to use the following methods:get
     * 
     * @param type repository type 
     * @return repository module class or null if type is not found 
     */ 
    public Class<? extends Module> type(String type) { 
        return repositoryTypes.get(type); 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:get, entrySet, size
    public void testImmutableSortedMap( ObjectMapperTester<ImmutableSortedMap<Integer, Boolean>> mapper ) {
        String json = mapper.write( ImmutableSortedMap.of( 12, true, 4, false ) );
        assertEquals( "{\"4\":false,\"12\":true}", json );
 
        ImmutableSortedMap<Integer, Boolean> map = mapper.read( "{\"12\":true,\"4\":false}" );
        assertEquals( 2, map.size() );
        assertEquals( Boolean.TRUE, map.get( Integer.valueOf( 12 ) ) );
        assertEquals( Boolean.FALSE, map.get( Integer.valueOf( 4 ) ) );
 
        Iterator<Entry<Integer, Boolean>> iterator = map.entrySet().iterator();
 
        Entry<Integer, Boolean> entry = iterator.next();
        assertEquals( Integer.valueOf( 4 ), entry.getKey() );
        assertFalse( entry.getValue() );
 
        entry = iterator.next();
        assertEquals( Integer.valueOf( 12 ), entry.getKey() );
        assertTrue( entry.getValue() );
    } 
 
6
CodeRank
This code example shows how to use the following methods:get
        return false; 
    } 
 
    @Override 
    public Object compile(String script) { 
        NativeScriptFactory scriptFactory = scripts.get(script); 
        if (scriptFactory != null) { 
            return scriptFactory; 
        } 
        throw new ElasticsearchIllegalArgumentException("Native script [" + script + "] not found"); 
    } 
 
    @Override 
    public ExecutableScript executable(Object compiledScript, @Nullable Map<String, Object> vars) { 
        NativeScriptFactory scriptFactory = (NativeScriptFactory) compiledScript; 
        return scriptFactory.newScript(vars); 
    } 
 
    @Override 
    public SearchScript search(Object compiledScript, SearchLookup lookup, @Nullable Map<String, Object> vars) { 
6
CodeRank
This code example shows how to use the following methods:containsKey, get
                || fieldName.equals("targetCompatibility") // handled directly by AntScalaCompiler
                || fieldName.equals("optimize") && !optimize;
    } 
 
    protected String getAntPropertyName(String fieldName) {
        if (FIELD_NAMES_TO_ANT_PROPERTIES.containsKey(fieldName)) {
            return FIELD_NAMES_TO_ANT_PROPERTIES.get(fieldName);
        } 
        return fieldName;
    } 
 
    protected Object getAntPropertyValue(String fieldName, Object value) {
        if (fieldName.equals("deprecation")) {
            return toOnOffString(isDeprecation()); 
        } 
        if (fieldName.equals("unchecked")) {
            return toOnOffString(isUnchecked()); 
        } 
        if (fieldName.equals("optimize")) {
            return toOnOffString(isOptimize()); 
6
CodeRank
See Code Examples for Guava ImmutableMap Methods: