private void addToParticipants(final Participant participant) { // check for no-op if (participant == null || getParticipants().contains(participant)) { return; } // dissociate arg from its current parent (if any). participant.getActivities().remove(this); // associate arg participant.getActivities().add(this); getParticipants().add(participant); // additional business logic // onAddToParticipants(participant); }
private void removeFromParticipants(final Participant participant) { // check for no-op if (participant == null || !getParticipants().contains(participant)) { return; } // dissociate arg participant.getActivities().remove(this); getParticipants().remove(participant); // additional business logic // onRemoveFromParticipants(partipipant); }