blob: 55409092fbf340c9e299c7680029fb96e83c0ae2 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004-2008 Andras Schmidt, Andras Balogh, Istvan Rath and Daniel Varro
* 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
*
* Contributors:
* Andras Schmidt, Andras Balogh, Istvan Rath - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.core.simple.notification;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.viatra2.core.ICoreNotificationListener;
import org.eclipse.viatra2.core.IModelElement;
import org.eclipse.viatra2.core.notification.ICoreNotificationObject;
import org.eclipse.viatra2.core.simple.SimpleModelElement;
/**
* The base class implementing the Viatra Notification object. It is essentially
* a data transfer object (DTO), serving as the basis of communication.
*
* @author Andras Schmidt
*
* Modified on 2006.08.09 by Istvan Rath: - cleaned up javadoc
*/
public abstract class NotificationObject implements ICoreNotificationObject {
String type = "";
Set<ICoreNotificationListener> listeners = new HashSet<ICoreNotificationListener>();
Set<IModelElement> notifiedObjects = new HashSet<IModelElement>();
public IModelElement getModelElement() {
return null;
}
public String getActionType() {
return getActionTypeEnum().toString();
}
public Collection<ICoreNotificationListener> getListeners() {
return listeners;
}
public String toString() {
return getActionTypeEnum().toString();
}
void addListener(IModelElement me) {
if (me != null) {
notifiedObjects.add(me);
if (me instanceof SimpleModelElement)
listeners.addAll(((SimpleModelElement) me)
.getNotificationListeners());
}
}
public Collection<IModelElement> getNotifiedObjects() {
return notifiedObjects;
}
}