All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kt3k.straw.StrawEventHandlerRepository Maven / Gradle / Ivy

The newest version!
package org.kt3k.straw;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class StrawEventHandlerRepository {

	private final Map> store = new HashMap>();

	public void store(StrawEventHandler handler) {

		// null check
		if (handler == null) {
			return;
		}

		String eventName = handler.getEventName();

		List list = this.store.get(eventName);

		if (list == null) {
			list = new ArrayList();

			this.store.put(eventName, list);
		}

		list.add(handler);
	}

	public void store(List handlers) {

		// null check
		if (handlers == null) {
			return;
		}

		for (StrawEventHandler handler: handlers) {
			this.store(handler);
		}

	}

	public List get(String eventName) {
		return this.store.get(eventName);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy