org.eclipse.emf.ecore.util
Class ComposedSwitch<T>

java.lang.Object
  extended by org.eclipse.emf.ecore.util.Switch<T>
      extended by org.eclipse.emf.ecore.util.ComposedSwitch<T>

public class ComposedSwitch<T>
extends Switch<T>

Composes multiple switches in order to handle instances of classes defined in multiple packages.

Since:
2.7

Constructor Summary
ComposedSwitch()
          Creates a new ComposedSwitch.
ComposedSwitch(java.util.Collection<? extends Switch<T>> switches)
          Creates a new ComposedSwitch.
 
Method Summary
 void addSwitch(Switch<T> sw)
           
protected  T delegatedDoSwitch(Switch<T> delegate, EClass theEClass, EObject theEObject)
          Call delegate.
protected  T doSwitch(EClass theEClass, EObject theEObject)
          Calls caseXXX for each (super-)class of the model until one returns a non-null result; it yields that result.
protected  Switch<T> findDelegate(EPackage ePackage)
          Finds a suitable delegate for the given package.
 boolean isSwitchFor(EPackage ePackage)
          Indicates whether the receiver is a switch for the specified package.
 void removeSwitch(Switch<T> sw)
           
 
Methods inherited from class org.eclipse.emf.ecore.util.Switch
defaultCase, doSwitch, doSwitch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComposedSwitch

public ComposedSwitch()
Creates a new ComposedSwitch.


ComposedSwitch

public ComposedSwitch(java.util.Collection<? extends Switch<T>> switches)
Creates a new ComposedSwitch.

Parameters:
switches - The switches to which the composed switch will delegate. The list should generally include switches for all the packages the composed switch will be expected to handle.
Method Detail

addSwitch

public void addSwitch(Switch<T> sw)

removeSwitch

public void removeSwitch(Switch<T> sw)

doSwitch

protected T doSwitch(EClass theEClass,
                     EObject theEObject)
Description copied from class: Switch
Calls caseXXX for each (super-)class of the model until one returns a non-null result; it yields that result.

Overrides:
doSwitch in class Switch<T>
Parameters:
theEClass - the class or superclass of eObject to consider. The class's containing EPackage determines whether the receiving switch object can handle the request.
theEObject - the model object to pass to the appropriate caseXXX.
Returns:
the first non-null result returned by a caseXXX call.

delegatedDoSwitch

protected T delegatedDoSwitch(Switch<T> delegate,
                              EClass theEClass,
                              EObject theEObject)
Call delegate.doSwitch(theEClass, theEObject).

Since:
2.8

findDelegate

protected Switch<T> findDelegate(EPackage ePackage)
Finds a suitable delegate for the given package.

Since:
2.8

isSwitchFor

public boolean isSwitchFor(EPackage ePackage)
Description copied from class: Switch
Indicates whether the receiver is a switch for the specified package.

Specified by:
isSwitchFor in class Switch<T>
Parameters:
ePackage - the package of interest.
Returns:
true if the receiver is a switch for package.

Copyright 2001-2012 IBM Corporation and others.
All Rights Reserved.