Java 8 HashMap - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 HashMap class.

This code example shows how to use the following methods:
			soundMap = new HashMap<String, Integer>();
		} 
		 
		if ( streamMap == null) 
		{ 
			streamMap = new HashMap<String, ArrayList<Integer>>();
		} 
		 
		if ( assetMap ==null ) 
		{ 
			assetMap = new HashMap<String, PGLowLatencyAudioAsset>();
		} 
	} 
} 
10
CodeRank
This code example shows how to use the following methods:
 */ 
public abstract class DataParser { 
 
    // ~~~~~~~~ Repository  
    public abstract Map<String, String[]> parse(InputStream is);    
    public static Map<String, DataParser> parsers = new HashMap<String, DataParser>();    
 
    // These are our injected Parser. Maybe we later want to allow dynamic injection 
    static { 
        parsers.put("application/x-www-form-urlencoded", new UrlEncodedParser());
        parsers.put("multipart/form-data", new ApacheMultipartParser());
        parsers.put("multipart/mixed", new ApacheMultipartParser());
        parsers.put("application/xml", new TextParser());
        parsers.put("application/json", new TextParser());
    } 
 
    public static void putMapEntry(Map<String, String[]> map, String name, String value) {
        String[] newValues = null;
        String[] oldValues = map.get(name);
        if (oldValues == null) {
10
CodeRank
This code example shows how to use the following methods:
/** 
 * A localized object 
 */ 
public class Localized<T> { 
 
    private Map<String, T> values = new HashMap<String, T>();
 
    public void set(T value) {
        this.values.put(Lang.get(), value);
    } 
 
    public void set(String lang, T value) {
        this.values.put(lang, value);
    } 
 
    public T get() { 
        return this.values.get(Lang.get());
    } 
 
    public T get(String lang) {
10
CodeRank
This code example shows how to use the following methods:put
        result.putExtra("com.jakewharton.android.viewpagerindicator.sample.Path", path);
        return result;
    } 
 
    protected void addItem(List<Map<String, Object>> data, String name, Intent intent) {
        Map<String, Object> temp = new HashMap<String, Object>();
        temp.put("title", name);
        temp.put("intent", intent);
        data.add(temp);
    } 
 
    @Override 
    @SuppressWarnings("unchecked") 
    protected void onListItemClick(ListView l, View v, int position, long id) {
        Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);
 
        Intent intent = (Intent) map.get("intent");
        startActivity(intent);
    } 
} 
9
CodeRank
This code example shows how to use the following methods:put
    } 
 
    private void deployParticipant() { 
        undeployServlet(); 
 
        final Map<String, String> initialParameters = new HashMap<String, String>();
        initialParameters.put("javax.ws.rs.Application", "org.wildfly.extension.rts.jaxrs.VolatileParticipantApplication");
 
        final DeploymentInfo participantDeploymentInfo = getDeploymentInfo(DEPLOYMENT_NAME, CONTEXT_PATH, initialParameters);
 
        deployServlet(participantDeploymentInfo);
    } 
 
} 
9
CodeRank
This code example shows how to use the following methods:
{ 
	private static final String TAG = "TestHarnessRunner";
	private static final String ARGUMENT_CLASS = "class";
 
	protected String activityClassName;
	protected HashMap<String, String> exceptions = new HashMap<String, String>();
 
	@Override 
	public void onCreate(Bundle arguments)
	{ 
		super.onCreate(arguments);
		if (arguments != null) {
			activityClassName = arguments.getString(ARGUMENT_CLASS);
		} 
		if (activityClassName == null) {
			Log.e(TAG, "No \"class\" parameter provided, exiting.");
			finish(Activity.RESULT_CANCELED, new Bundle());
		} 
		else { 
			start();
10
CodeRank
This code example shows how to use the following methods:put
        String groovySrc = "hello world: ${name}";
 
        GroovyTemplate t = new GroovyTemplate("Template_123", groovySrc);
        new GroovyTemplateCompiler().compile(t);
 
        Map<String, Object> args = new HashMap<String,Object>();
        args.put("name", "Morten");
        assertThat( t.render( args ) ).isEqualTo("hello world: Morten");
 
        //do it again 
        assertThat( t.render( args ) ).isEqualTo("hello world: Morten");
 
    } 
 
    @Test 
    public void verifyCompilingExtremelyLongLines() { 
        StringBuilder longString = new StringBuilder();
        for (int i=0;i<1000;i++) {
            longString.append("11111111112222222222333333333344444444445555555555");
            longString.append("11111111112222222222333333333344444444445555555555");
9
CodeRank
This code example shows how to use the following methods:put
    } 
 
    private void deployParticipant() { 
        undeployServlet(); 
 
        final Map<String, String> initialParameters = new HashMap<String, String>();
        initialParameters.put("javax.ws.rs.Application", "org.wildfly.extension.rts.jaxrs.ParticipantApplication");
 
        final DeploymentInfo participantDeploymentInfo = getDeploymentInfo(DEPLOYMENT_NAME, CONTEXT_PATH, initialParameters);
 
        deployServlet(participantDeploymentInfo);
    } 
 
} 
9
CodeRank
This code example shows how to use the following methods:put
        mapping.parseQuery("foo", parser);
    } 
     
    @Test
    public void testHashcode() throws Exception {
        HashMap<String, Object> config = new HashMap<>();
        if (randomBoolean()) { 
            config.put("precision", Arrays.asList(1, 2, 3, 4));
        } else { 
            config.put("precision", randomIntBetween(1, 12)); 
        } 
        if (randomBoolean()) { 
            HashMap<String, Double> pointAsMap = new HashMap<>();
            pointAsMap.put("lat", 51d);
            pointAsMap.put("lon", 0d);
            config.put("default", pointAsMap);
        } 
        HashMap<String, Object> config2 = new HashMap<>(config);
        GeolocationContextMapping mapping = GeolocationContextMapping.load("foo", config);
        GeolocationContextMapping mapping2 = GeolocationContextMapping.load("foo", config2);

8
CodeRank
This code example shows how to use the following methods:
 
    public Map<KeyColumn, S> getLocksForTx(StoreTransaction tx) {
        Map<KeyColumn, S> m = locks.get(tx);
 
        if (null == m) {
            m = new HashMap<KeyColumn, S>();
            final Map<KeyColumn, S> x = locks.putIfAbsent(tx, m);
            if (null != x) {
                m = x;
            } 
        } 
 
        return m;
    } 
} 
10
CodeRank

Related Java 8 HashMap Questions & Answers:

Other Java 8 HashMap Examples

1:		 * Get stored session data
2:		 * */
3:		public HashMap<String, String> getUserDetails(){
4:			HashMap<String, String> user = new HashMap<String, String>();
5:			// user name
-
2:		 * */
3:		public HashMap<String, String> getUserDetails(){
4:			HashMap<String, String> user = new HashMap<String, String>();
5:			// user name
6:			user.put(KEY_NAME, pref.getString(KEY_NAME, null));
-
2:		 * */
3:		public HashMap<String, String> getUserDetails(){
4:			HashMaping> user = new HashMap<String, String>();
5:			// user name
6:			user.put(KEY_NAME, pref.getString(KEY_NAME, null));

Read More

30:				@Override
31:				public Map<String, String> getHeaders() throws AuthFailureError {
32:					HashMap<String, String> headers = new HashMap<String, String>();
33:					headers.put("Content-Type", "application/json");
34:					headers.put("apiKey", "xxxxxxxxxxxxxxx");
-
30:				@Override
31:				public Map<String, String> getHeaders() throws AuthFailureError {
32:					HashMap> headers = new HashMap<String, String>();
33:					headers.put("Content-Type", "application/json");
34:					headers.put("apiKey", "xxxxxxxxxxxxxxx");

Read More

24:				for (File file : home.listFiles(new FileExtensionFilter())) {
25:					HashMap<String, String> song = new HashMap<String, String>();
26:					song.put("songTitle", file.getName().substring(0, (file.getName().length() - 4)));
27:					song.put("songPath", file.getPath());
28:	
-
24:				for (File file : home.listFiles(new FileExtensionFilter())) {
25:					HashMap<String, String> song = new HashMap<String, String>();
26:					song.put("songTitle", file.getName().substring(0, (file.getName().length() - 4)));
27:					song.put("songPath", file.getPath());
28:

Read More

See Code Examples for Java 8 HashMap Methods: