/** * Sets the {@link RoutingModule} to use for the given (main) mode. * @param mainMode the mode * @param module the module to use with this mode * @return the previously registered {@link RoutingModule} for this mode if any, null otherwise. */ @Deprecated // use the Builder instead. kai, oct'17 /* package-private */ RoutingModule setRoutingModule( final String mainMode, final RoutingModule module) { RoutingModule old = routingModules.put( mainMode , module ); if (old != null) { final StageActivityTypes oldTypes = old.getStageActivityTypes(); final boolean removed = checker.removeActivityTypes( oldTypes ); if ( !removed ) { throw new RuntimeException( "could not remove "+oldTypes+" associated to "+old+". This may be due to a routing module creating a new instance at each call of getStageActivityTypes()" ); } } final StageActivityTypes types = module.getStageActivityTypes(); if ( types == null ) { // we do not want to accept that, this would risk to mess up // with replacement, and it generally makes code messy. throw new RuntimeException( module+" returns null stage activity types. This is not a valid value. Return EmptyStageActivityTypes.INSTANCE instead." ); } checker.addActivityTypes( types ); return old; }