001package org.biopax.paxtools.io.sif;
002
003import org.biopax.paxtools.util.AccessibleSet;
004
005/**
006 * This is a set of binary interactions. When a new interactions is added, if the pair already
007 * exists, only the mediators are updated with new information.
008 */
009public class InteractionSet extends AccessibleSet<SimpleInteraction>
010{
011        /**
012         * If the interaction already exists, mediators are updated with merging.
013         * @param simpleInteraction interaction to add
014         * @return always true
015         */
016        @Override public boolean add(SimpleInteraction simpleInteraction)
017        {
018
019                SimpleInteraction existing = access(simpleInteraction);
020                if (existing == null)
021                {
022                        existing = simpleInteraction;
023                        super.add(existing);
024                }
025                else
026                {
027                        existing.getMediators().addAll(simpleInteraction.getMediators());
028                }
029                return true;
030        }
031}