/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.33.0.6934.a386b0a58 modeling language!*/

package example;
import java.util.*;

// line 3 "../ImmutableUnidirectionalManyTest.ump"
public class Student
{

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

  //Student Attributes
  private String number;

  //Student Associations
  private List<Mentor> mentors;

  //Helper Variables
  private boolean canSetMentors;

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

  public Student(String aNumber, Mentor... allMentors)
  {
    number = aNumber;
    canSetMentors = true;
    mentors = new ArrayList<Mentor>();
    boolean didAddMentors = setMentors(allMentors);
    if (!didAddMentors)
    {
      throw new RuntimeException("Unable to create Student, must not have duplicate mentors. See http://manual.umple.org?RE001ViolationofImmutability.html");
    }
  }

  //------------------------
  // INTERFACE
  //------------------------

  public String getNumber()
  {
    return number;
  }
  /* Code from template association_GetMany */
  public Mentor getMentor(int index)
  {
    Mentor aMentor = mentors.get(index);
    return aMentor;
  }

  public List<Mentor> getMentors()
  {
    List<Mentor> newMentors = Collections.unmodifiableList(mentors);
    return newMentors;
  }

  public int numberOfMentors()
  {
    int number = mentors.size();
    return number;
  }

  public boolean hasMentors()
  {
    boolean has = mentors.size() > 0;
    return has;
  }

  public int indexOfMentor(Mentor aMentor)
  {
    int index = mentors.indexOf(aMentor);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfMentors()
  {
    return 0;
  }
  /* Code from template association_SetUnidirectionalMany */
  private boolean setMentors(Mentor... newMentors)
  {
    boolean wasSet = false;
    if (!canSetMentors) { return false; }
    canSetMentors = false;
    ArrayList<Mentor> verifiedMentors = new ArrayList<Mentor>();
    for (Mentor aMentor : newMentors)
    {
      if (verifiedMentors.contains(aMentor))
      {
        continue;
      }
      verifiedMentors.add(aMentor);
    }

    if (verifiedMentors.size() != newMentors.length)
    {
      return wasSet;
    }

    mentors.clear();
    mentors.addAll(verifiedMentors);
    wasSet = true;
    return wasSet;
  }

  public void delete()
  {}


  public String toString()
  {
    return super.toString() + "["+
            "number" + ":" + getNumber()+ "]";
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.33.0.6934.a386b0a58 modeling language!*/

package example;

// line 9 "../ImmutableUnidirectionalManyTest.ump"
public class Mentor
{

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

  //Mentor Attributes
  private String name;

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

  public Mentor(String aName)
  {
    name = aName;
  }

  //------------------------
  // INTERFACE
  //------------------------

  public String getName()
  {
    return name;
  }

  public void delete()
  {}


  public String toString()
  {
    return super.toString() + "["+
            "name" + ":" + getName()+ "]";
  }
}