/** sets the outgoingTransitions to the given list of outgoingTransitions. * A copy of the collection is made. Also the outgoingTransitionsMap will * be updated and the source of all the transitions in the given list will * be set to this node. * In case there was a leaving transitions list present, these transition's * source will be nulled. */ public void setOutgoingTransitions(List<TransitionImpl> outgoingTransitions) { if (this.outgoingTransitions!=null) { for (TransitionImpl removedTransition: this.outgoingTransitions) { removedTransition.setSource(null); } } if (outgoingTransitions!=null) { this.outgoingTransitions = new ArrayList<TransitionImpl>(outgoingTransitions); for (TransitionImpl addedTransition: outgoingTransitions) { addedTransition.setSource(this); } } else { this.outgoingTransitions = null; } this.outgoingTransitionsMap = null; }
/** * adds the given transition as a leaving transition to this node. * Also the source of the transition is set to this node. * Adding a transition that is already contained in the leaving * transitions has no effect. * @return the added transition. * @throws NullPointerException if transition is null. */ public Transition addOutgoingTransition(TransitionImpl transition) { transition.setSource(this); if (outgoingTransitions==null) { outgoingTransitions = new ArrayList<TransitionImpl>(); } if (! outgoingTransitions.contains(transition)) { outgoingTransitions.add(transition); } outgoingTransitionsMap = null; return transition; }
/** * removes the given transition from the leaving transitions. * Also the transition's source will be nulled. * This method will do nothing if the transition is null or if * the given transition is not in the list of this node's leaving * transitions. * In case this is the transition that was in the * outgoingTransitionsMap and another transition exists with the same * name, that transition (the first) will be put in the * outgoingTransitionsMap as a replacement for the removed transition. * If the transition is actually removed from the list of * leaving transitions, the transition's source will be nulled. */ public boolean removeOutgoingTransition(TransitionImpl transition) { if ( (transition!=null) && (outgoingTransitions!=null) ) { boolean isRemoved = outgoingTransitions.remove(transition); if (isRemoved) { transition.setSource(null); if (outgoingTransitions.isEmpty()) { outgoingTransitions = null; } outgoingTransitionsMap = null; } return isRemoved; } return false; }