/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.31.1.5860.78bb27cc6 modeling language!*/

package example;
import java.util.*;

// line 3 "../ManyToManySubclassTest.ump"
public class Analyzer
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Analyzer Associations
  private List<Analyzer> children;
  private List<Analyzer> parent;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Analyzer()
  {
    children = new ArrayList<Analyzer>();
    parent = new ArrayList<Analyzer>();
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetMany */
  public Analyzer getChild(int index)
  {
    Analyzer aChild = children.get(index);
    return aChild;
  }

  public List<Analyzer> getChildren()
  {
    List<Analyzer> newChildren = Collections.unmodifiableList(children);
    return newChildren;
  }

  public int numberOfChildren()
  {
    int number = children.size();
    return number;
  }

  public boolean hasChildren()
  {
    boolean has = children.size() > 0;
    return has;
  }

  public int indexOfChild(Analyzer aChild)
  {
    int index = children.indexOf(aChild);
    return index;
  }
  /* Code from template association_GetMany */
  public Analyzer getParent(int index)
  {
    Analyzer aParent = parent.get(index);
    return aParent;
  }

  public List<Analyzer> getParent()
  {
    List<Analyzer> newParent = Collections.unmodifiableList(parent);
    return newParent;
  }

  public int numberOfParent()
  {
    int number = parent.size();
    return number;
  }

  public boolean hasParent()
  {
    boolean has = parent.size() > 0;
    return has;
  }

  public int indexOfParent(Analyzer aParent)
  {
    int index = parent.indexOf(aParent);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfChildren()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addChild(Analyzer aChild)
  {
    boolean wasAdded = false;
    if (children.contains(aChild)) { return false; }
    children.add(aChild);
    if (aChild.indexOfParent(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aChild.addParent(this);
      if (!wasAdded)
      {
        children.remove(aChild);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeChild(Analyzer aChild)
  {
    boolean wasRemoved = false;
    if (!children.contains(aChild))
    {
      return wasRemoved;
    }

    int oldIndex = children.indexOf(aChild);
    children.remove(oldIndex);
    if (aChild.indexOfParent(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aChild.removeParent(this);
      if (!wasRemoved)
      {
        children.add(oldIndex,aChild);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addChildAt(Analyzer aChild, int index)
  {  
    boolean wasAdded = false;
    if(addChild(aChild))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfChildren()) { index = numberOfChildren() - 1; }
      children.remove(aChild);
      children.add(index, aChild);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveChildAt(Analyzer aChild, int index)
  {
    boolean wasAdded = false;
    if(children.contains(aChild))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfChildren()) { index = numberOfChildren() - 1; }
      children.remove(aChild);
      children.add(index, aChild);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addChildAt(aChild, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfParent()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addParent(Analyzer aParent)
  {
    boolean wasAdded = false;
    if (parent.contains(aParent)) { return false; }
    parent.add(aParent);
    if (aParent.indexOfChild(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aParent.addChild(this);
      if (!wasAdded)
      {
        parent.remove(aParent);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeParent(Analyzer aParent)
  {
    boolean wasRemoved = false;
    if (!parent.contains(aParent))
    {
      return wasRemoved;
    }

    int oldIndex = parent.indexOf(aParent);
    parent.remove(oldIndex);
    if (aParent.indexOfChild(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aParent.removeChild(this);
      if (!wasRemoved)
      {
        parent.add(oldIndex,aParent);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addParentAt(Analyzer aParent, int index)
  {  
    boolean wasAdded = false;
    if(addParent(aParent))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfParent()) { index = numberOfParent() - 1; }
      parent.remove(aParent);
      parent.add(index, aParent);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveParentAt(Analyzer aParent, int index)
  {
    boolean wasAdded = false;
    if(parent.contains(aParent))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfParent()) { index = numberOfParent() - 1; }
      parent.remove(aParent);
      parent.add(index, aParent);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addParentAt(aParent, index);
    }
    return wasAdded;
  }

  public void delete()
  {
    ArrayList<Analyzer> copyOfChildren = new ArrayList<Analyzer>(children);
    children.clear();
    for(Analyzer aChild : copyOfChildren)
    {
      aChild.removeParent(this);
    }
    ArrayList<Analyzer> copyOfParent = new ArrayList<Analyzer>(parent);
    parent.clear();
    for(Analyzer aParent : copyOfParent)
    {
      aParent.removeChild(this);
    }
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.31.1.5860.78bb27cc6 modeling language!*/

package example;
import java.util.*;

// line 5 "../ManyToManySubclassTest2.ump"
public class Analyzer
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Analyzer Associations
  private List<X> offspring;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Analyzer()
  {
    offspring = new ArrayList<X>();
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetMany */
  public X getOffspring(int index)
  {
    X aOffspring = offspring.get(index);
    return aOffspring;
  }

  public List<X> getOffspring()
  {
    List<X> newOffspring = Collections.unmodifiableList(offspring);
    return newOffspring;
  }

  public int numberOfOffspring()
  {
    int number = offspring.size();
    return number;
  }

  public boolean hasOffspring()
  {
    boolean has = offspring.size() > 0;
    return has;
  }

  public int indexOfOffspring(X aOffspring)
  {
    int index = offspring.indexOf(aOffspring);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfOffspring()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addOffspring(X aOffspring)
  {
    boolean wasAdded = false;
    if (offspring.contains(aOffspring)) { return false; }
    offspring.add(aOffspring);
    if (aOffspring.indexOfParent(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aOffspring.addParent(this);
      if (!wasAdded)
      {
        offspring.remove(aOffspring);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeOffspring(X aOffspring)
  {
    boolean wasRemoved = false;
    if (!offspring.contains(aOffspring))
    {
      return wasRemoved;
    }

    int oldIndex = offspring.indexOf(aOffspring);
    offspring.remove(oldIndex);
    if (aOffspring.indexOfParent(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aOffspring.removeParent(this);
      if (!wasRemoved)
      {
        offspring.add(oldIndex,aOffspring);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addOffspringAt(X aOffspring, int index)
  {  
    boolean wasAdded = false;
    if(addOffspring(aOffspring))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOffspring()) { index = numberOfOffspring() - 1; }
      offspring.remove(aOffspring);
      offspring.add(index, aOffspring);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveOffspringAt(X aOffspring, int index)
  {
    boolean wasAdded = false;
    if(offspring.contains(aOffspring))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOffspring()) { index = numberOfOffspring() - 1; }
      offspring.remove(aOffspring);
      offspring.add(index, aOffspring);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addOffspringAt(aOffspring, index);
    }
    return wasAdded;
  }

  public void delete()
  {
    ArrayList<X> copyOfOffspring = new ArrayList<X>(offspring);
    offspring.clear();
    for(X aOffspring : copyOfOffspring)
    {
      aOffspring.removeParent(this);
    }
  }

}