public boolean removeParticipant(T part) { if (part == null){ return false; } if (getParticipants().remove(part)){ part.setInteraction(null); return true; } return false; }
public boolean addParticipant(T part) { if (part == null){ return false; } if (getParticipants().add(part)){ part.setInteraction(this); return true; } return false; }
public boolean removeAll(Collection<?> objects) { boolean remove = candidates.removeAll(objects); if (remove){ Collection<Interactor> interactors = new ArrayList<Interactor>(objects.size()); for (Object o : objects){ Participant entity = (Participant)o; entity.setChangeListener(null); interactors.add(entity.getInteractor()); entity.setInteraction(null); } // check if an interactor is not in another entity that is kept. // remove any interactors that are kept with other entities for (P entity : this){ interactors.remove(entity.getInteractor()); } getInteractor().removeAll(interactors); } return remove; }
/** * Adds a new Participant and set the Interaction of this participant if added. * If the participant B and A are null, it will first set the participantA. If the participantA is set, it will set the ParticipantB * @param part : participant to add * @return true if the participant has been added, false otherwise * @throws IllegalArgumentException if this Binary interaction already contains two participants */ public boolean addParticipant(T part) { if (part == null){ return false; } if (getParticipantB() != null && getParticipantA() != null){ throw new IllegalStateException("A ModelledBinaryInteraction cannot have more than two participants."); } else if (getParticipantA() != null){ part.setInteraction(this); setParticipantB(part); return true; } else{ part.setInteraction(this); setParticipantA(part); return true; } }
/** * Adds a new Participant and set the Interaction of this participant if added. * If the participant B and A are null, it will first set the participantA. If the participantA is set, it will set the ParticipantB * @param part : participant to add * @return true if the participant has been added, false otherwise * @throws IllegalArgumentException if this Binary interaction already contains two participants */ @Override public boolean addParticipant(T part) { if (part == null){ return false; } if (getParticipantB() != null && getParticipantA() != null){ throw new IllegalStateException("A BinaryInteraction cannot have more than two participants."); } else if (getParticipantA() != null){ part.setInteraction(this); setParticipantB(part); return true; } else{ part.setInteraction(this); setParticipantA(part); return true; } }
/** * Removes the Participant from this binary interaction * @param part : participant to remove * @return true if the participant has been removed, false otherwise */ public boolean removeParticipant(T part) { if (part == null){ return false; } if (getParticipantA() != null && getParticipantA().equals(part)){ part.setInteraction(null); setParticipantA(null); return true; } else if (getParticipantB() != null && getParticipantB().equals(part)){ part.setInteraction(null); setParticipantB(null); return true; } return false; }
/** * Removes the Participant from this binary interaction * @param part : participant to remove * @return true if the participant has been removed, false otherwise */ @Override public boolean removeParticipant(T part) { if (part == null){ return false; } if (getParticipantA() != null && getParticipantA().equals(part)){ part.setInteraction(null); setParticipantA(null); return true; } else if (getParticipantB() != null && getParticipantB().equals(part)){ part.setInteraction(null); setParticipantB(null); return true; } return false; }