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

org.eclipse.xtext.resource.impl.AbstractResourceDescriptionChangeEventSource Maven / Gradle / Ivy

There is a newer version: 2.4.3
Show newest version
/*******************************************************************************
 * Copyright (c) 2009 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtext.resource.impl;

import java.util.Collection;
import java.util.concurrent.CopyOnWriteArraySet;

import org.eclipse.xtext.resource.IResourceDescription;

/**
 * @author Sebastian Zarnekow - Initial contribution and API
 */
public class AbstractResourceDescriptionChangeEventSource implements IResourceDescription.Event.Source {

	private Collection listenerList;
	
	protected AbstractResourceDescriptionChangeEventSource() {
		listenerList = new CopyOnWriteArraySet();
	}
	
	public void addListener(IResourceDescription.Event.Listener listener) {
		listenerList.add(listener);
	}
	
	public void addListeners(Collection listeners) {
		listenerList.addAll(listeners);
	}

	public void removeListener(IResourceDescription.Event.Listener listener) {
		listenerList.remove(listener);
	}
	
	public void removeListeners(Collection listeners) {
		listenerList.removeAll(listeners);
	}
	
	protected void notifyListeners(IResourceDescription.Event event) {
		if (event == null)
			throw new IllegalArgumentException("event may not be null");
		for(IResourceDescription.Event.Listener listener: listenerList) {
			listener.descriptionsChanged(event);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy