/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package metamodel.mmaemilia.Behavior.provider;

import java.util.ArrayList;
import java.util.Collection;

import metamodel.mmaemilia.Behavior.util.BehaviorAdapterFactory;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class BehaviorItemProviderAdapterFactory extends BehaviorAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BehaviorItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.Behavior} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BehaviorItemProvider behaviorItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.Behavior}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createBehaviorAdapter() {
		if (behaviorItemProvider == null) {
			behaviorItemProvider = new BehaviorItemProvider(this);
		}

		return behaviorItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.BehavEquation} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BehavEquationItemProvider behavEquationItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.BehavEquation}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createBehavEquationAdapter() {
		if (behavEquationItemProvider == null) {
			behavEquationItemProvider = new BehavEquationItemProvider(this);
		}

		return behavEquationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.ProcessTerm} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProcessTermItemProvider processTermItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.ProcessTerm}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createProcessTermAdapter() {
		if (processTermItemProvider == null) {
			processTermItemProvider = new ProcessTermItemProvider(this);
		}

		return processTermItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.Stop} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StopItemProvider stopItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.Stop}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createStopAdapter() {
		if (stopItemProvider == null) {
			stopItemProvider = new StopItemProvider(this);
		}

		return stopItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.ChoiceProcess} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChoiceProcessItemProvider choiceProcessItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.ChoiceProcess}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createChoiceProcessAdapter() {
		if (choiceProcessItemProvider == null) {
			choiceProcessItemProvider = new ChoiceProcessItemProvider(this);
		}

		return choiceProcessItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.ActionProcess} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActionProcessItemProvider actionProcessItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.ActionProcess}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createActionProcessAdapter() {
		if (actionProcessItemProvider == null) {
			actionProcessItemProvider = new ActionProcessItemProvider(this);
		}

		return actionProcessItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.BehavProcess} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BehavProcessItemProvider behavProcessItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.BehavProcess}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createBehavProcessAdapter() {
		if (behavProcessItemProvider == null) {
			behavProcessItemProvider = new BehavProcessItemProvider(this);
		}

		return behavProcessItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.Action} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActionItemProvider actionItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.Action}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createActionAdapter() {
		if (actionItemProvider == null) {
			actionItemProvider = new ActionItemProvider(this);
		}

		return actionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.ActionType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActionTypeItemProvider actionTypeItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.ActionType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createActionTypeAdapter() {
		if (actionTypeItemProvider == null) {
			actionTypeItemProvider = new ActionTypeItemProvider(this);
		}

		return actionTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.ActionInput} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActionInputItemProvider actionInputItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.ActionInput}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createActionInputAdapter() {
		if (actionInputItemProvider == null) {
			actionInputItemProvider = new ActionInputItemProvider(this);
		}

		return actionInputItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.ActionOutput} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActionOutputItemProvider actionOutputItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.ActionOutput}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createActionOutputAdapter() {
		if (actionOutputItemProvider == null) {
			actionOutputItemProvider = new ActionOutputItemProvider(this);
		}

		return actionOutputItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.RateExp} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RateExpItemProvider rateExpItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.RateExp}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRateExpAdapter() {
		if (rateExpItemProvider == null) {
			rateExpItemProvider = new RateExpItemProvider(this);
		}

		return rateExpItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.RateInf} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RateInfItemProvider rateInfItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.RateInf}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRateInfAdapter() {
		if (rateInfItemProvider == null) {
			rateInfItemProvider = new RateInfItemProvider(this);
		}

		return rateInfItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link metamodel.mmaemilia.Behavior.RatePas} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RatePasItemProvider ratePasItemProvider;

	/**
	 * This creates an adapter for a {@link metamodel.mmaemilia.Behavior.RatePas}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRatePasAdapter() {
		if (ratePasItemProvider == null) {
			ratePasItemProvider = new RatePasItemProvider(this);
		}

		return ratePasItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (behaviorItemProvider != null) behaviorItemProvider.dispose();
		if (behavEquationItemProvider != null) behavEquationItemProvider.dispose();
		if (processTermItemProvider != null) processTermItemProvider.dispose();
		if (stopItemProvider != null) stopItemProvider.dispose();
		if (choiceProcessItemProvider != null) choiceProcessItemProvider.dispose();
		if (actionProcessItemProvider != null) actionProcessItemProvider.dispose();
		if (behavProcessItemProvider != null) behavProcessItemProvider.dispose();
		if (actionItemProvider != null) actionItemProvider.dispose();
		if (actionTypeItemProvider != null) actionTypeItemProvider.dispose();
		if (actionInputItemProvider != null) actionInputItemProvider.dispose();
		if (actionOutputItemProvider != null) actionOutputItemProvider.dispose();
		if (rateExpItemProvider != null) rateExpItemProvider.dispose();
		if (rateInfItemProvider != null) rateInfItemProvider.dispose();
		if (ratePasItemProvider != null) ratePasItemProvider.dispose();
	}

}
