Innere nicht-statische abstrakte Switch-Klasse
generierte abstrakte Methoden verhindern
das Vergessen hinzugekommener Varianten/Zweige
/**
* Constraint class of ExampleContextObject (Z or N).
*/
public final class ORB_Z_N_OREConstraint {
/**
* Abstract typesafe switch class of ORB_Z_N_OREConstraint.
* @param <Ret> Type-Parameter, Return-Type of case method
*/
abstract public class Switch<Ret> {
/** To implement method for switch case value Z. */
abstract protected Ret caseZ( ZConstraint constraint );
/** To implement method for switch case value N. */
abstract protected Ret caseN( NConstraint constraint );
/** To call method for executing switch case. */
public final Ret doSwitch() {
if ( Z.test( ORB_Z_N_OREConstraint.this.contextObj ) ) {
return caseZ( new ZConstraint( this.contextObj ) );
}
if ( N.test( ORB_Z_N_OREConstraint.this.contextObj ) ) {
return caseR( new RConstraint( this.contextObj ) );
}
throw new IllegalStateException( "this will never occur" );
}