/*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../OptionalOneToOptionalOneTest.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //Mentor Associations private Student student; //------------------------ // CONSTRUCTOR //------------------------ public Mentor() {} //------------------------ // INTERFACE //------------------------ /* Code from template association_GetOne */ public Student getStudent() { return student; } public boolean hasStudent() { boolean has = student != null; return has; } /* Code from template association_SetOptionalOneToOptionalOne */ public boolean setStudent(Student aNewStudent) { boolean wasSet = false; if (aNewStudent == null) { Student existingStudent = student; student = null; if (existingStudent != null && existingStudent.getMentor() != null) { existingStudent.setMentor(null); } wasSet = true; return wasSet; } Student currentStudent = getStudent(); if (currentStudent != null && !currentStudent.equals(aNewStudent)) { currentStudent.setMentor(null); } student = aNewStudent; Mentor existingMentor = aNewStudent.getMentor(); if (!equals(existingMentor)) { aNewStudent.setMentor(this); } wasSet = true; return wasSet; } public void delete() { if (student != null) { student.setMentor(null); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 8 "../OptionalOneToOptionalOneTest.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //Student Associations private Mentor mentor; //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ /* Code from template association_GetOne */ public Mentor getMentor() { return mentor; } public boolean hasMentor() { boolean has = mentor != null; return has; } /* Code from template association_SetOptionalOneToOptionalOne */ public boolean setMentor(Mentor aNewMentor) { boolean wasSet = false; if (aNewMentor == null) { Mentor existingMentor = mentor; mentor = null; if (existingMentor != null && existingMentor.getStudent() != null) { existingMentor.setStudent(null); } wasSet = true; return wasSet; } Mentor currentMentor = getMentor(); if (currentMentor != null && !currentMentor.equals(aNewMentor)) { currentMentor.setStudent(null); } mentor = aNewMentor; Student existingStudent = aNewMentor.getStudent(); if (!equals(existingStudent)) { aNewMentor.setStudent(this); } wasSet = true; return wasSet; } public void delete() { if (mentor != null) { mentor.setStudent(null); } } }