/*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../ClassTemplateTest_FixmlAttributes1.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //Mentor Attributes private int id; //------------------------ // CONSTRUCTOR //------------------------ public Mentor(int aId) { id = aId; } public Mentor() { } //------------------------ // INTERFACE //------------------------ public boolean setId(int aId) { boolean wasSet = false; id = aId; wasSet = true; return wasSet; } public int getId() { return id; } public void delete() {} public String toString() { return super.toString() + "["+ "id" + ":" + getId()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../ClassTemplateTest_FixmlAttributes2.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //Mentor Attributes private String capacity; private int id; private String name; //------------------------ // CONSTRUCTOR //------------------------ public Mentor(String aCapacity, int aId, String aName) { capacity = aCapacity; id = aId; name = aName; } public Mentor() { capacity = "31"; name = "Umple"; } //------------------------ // INTERFACE //------------------------ public boolean setCapacity(String aCapacity) { boolean wasSet = false; capacity = aCapacity; wasSet = true; return wasSet; } public boolean setId(int aId) { boolean wasSet = false; id = aId; wasSet = true; return wasSet; } public boolean setName(String aName) { boolean wasSet = false; name = aName; wasSet = true; return wasSet; } public String getCapacity() { return capacity; } public int getId() { return id; } public String getName() { return name; } public void delete() {} public String toString() { return super.toString() + "["+ "capacity" + ":" + getCapacity()+ "," + "id" + ":" + getId()+ "," + "name" + ":" + getName()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../ClassTemplateTest_FixmlAttributes3.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //Mentor Attributes private String capacity; private int id; private String name; //------------------------ // CONSTRUCTOR //------------------------ public Mentor(String aCapacity, int aId, String aName) { capacity = aCapacity; id = aId; name = aName; } public Mentor() { capacity = "31"; name = "Umple"; System.out.println("Testing"); String test; } //------------------------ // INTERFACE //------------------------ public boolean setCapacity(String aCapacity) { boolean wasSet = false; capacity = aCapacity; wasSet = true; return wasSet; } public boolean setId(int aId) { boolean wasSet = false; id = aId; wasSet = true; return wasSet; } public boolean setName(String aName) { boolean wasSet = false; name = aName; wasSet = true; return wasSet; } public String getCapacity() { return capacity; } public int getId() { return id; } public String getName() { return name; } public void delete() {} public String toString() { return super.toString() + "["+ "capacity" + ":" + getCapacity()+ "," + "id" + ":" + getId()+ "," + "name" + ":" + getName()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "ClassTemplateTest_CodeInjectionsParametersUnspecified.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 3 "ClassTemplateTest_CodeInjectionsParametersUnspecified.ump" public String foo(int a){ // line 22 "ClassTemplateTest_CodeInjectionsParametersUnspecified.ump" System.out.println("Starting foo..."); // END OF UMPLE BEFORE INJECTION if(a < 0) { // line 18 "ClassTemplateTest_CodeInjectionsParametersUnspecified.ump" System.out.println("Returning from foo, a: " + a); // END OF UMPLE AFTER INJECTION return 4; } // line 18 "ClassTemplateTest_CodeInjectionsParametersUnspecified.ump" System.out.println("Returning from foo, a: " + a); // END OF UMPLE AFTER INJECTION return 3; } // line 11 "ClassTemplateTest_CodeInjectionsParametersUnspecified.ump" public String foo(int a, String b){ // line 22 "ClassTemplateTest_CodeInjectionsParametersUnspecified.ump" System.out.println("Starting foo..."); // END OF UMPLE BEFORE INJECTION if(a > 0 && "".equals(b)) { // line 18 "ClassTemplateTest_CodeInjectionsParametersUnspecified.ump" System.out.println("Returning from foo, a: " + a); // END OF UMPLE AFTER INJECTION return 3; } // line 18 "ClassTemplateTest_CodeInjectionsParametersUnspecified.ump" System.out.println("Returning from foo, a: " + a); // END OF UMPLE AFTER INJECTION return 1; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../ClassTemplateTest_Generated.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Mentor() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 6 "../ClassTemplateTest_Generated.ump" public static void main(String [] args){ Thread.currentThread().setUncaughtExceptionHandler(new UmpleExceptionHandler()); Thread.setDefaultUncaughtExceptionHandler(new UmpleExceptionHandler()); } public static class UmpleExceptionHandler implements Thread.UncaughtExceptionHandler { public void uncaughtException(Thread t, Throwable e) { translate(e); if(e.getCause()!=null) { translate(e.getCause()); } e.printStackTrace(); } public void translate(Throwable e) { java.util.List<StackTraceElement> result = new java.util.ArrayList<StackTraceElement>(); StackTraceElement[] elements = e.getStackTrace(); try { for(StackTraceElement element:elements) { String className = element.getClassName(); String methodName = element.getMethodName(); boolean methodFound = false; int index = className.lastIndexOf('.')+1; try { java.lang.reflect.Method query = this.getClass().getMethod(className.substring(index)+"_"+methodName,new Class[]{}); UmpleSourceData sourceInformation = (UmpleSourceData)query.invoke(this,new Object[]{}); for(int i=0;i<sourceInformation.size();++i) { // To compensate for any offsets caused by injected code we need to loop through the other references to this function // and adjust the start / length of the function. int functionStart = sourceInformation.getJavaLine(i) + (("main".equals(methodName))?3:1); int functionEnd = functionStart + sourceInformation.getLength(i); int afterInjectionLines = 0; // We can leverage the fact that all inject statements are added to the uncaught exception list // before the functions that they are within for (int j = 0; j < i; j++) { if (sourceInformation.getJavaLine(j) - 1 >= functionStart && sourceInformation.getJavaLine(j) - 1 <= functionEnd && sourceInformation.getJavaLine(j) - 1 <= element.getLineNumber()) { // A before injection, +2 for the comments surrounding the injected code if (sourceInformation.getJavaLine(j) - 1 == functionStart) { functionStart += sourceInformation.getLength(j) + 2; functionEnd += sourceInformation.getLength(j) + 2; } else { // An after injection afterInjectionLines += sourceInformation.getLength(j) + 2; functionEnd += sourceInformation.getLength(j) + 2; } } } int distanceFromStart = element.getLineNumber() - functionStart - afterInjectionLines; if(distanceFromStart>=0&&distanceFromStart<=sourceInformation.getLength(i)) { result.add(new StackTraceElement(element.getClassName(),element.getMethodName(),sourceInformation.getFileName(i),sourceInformation.getUmpleLine(i)+distanceFromStart)); methodFound = true; break; } } } catch (Exception e2){} if(!methodFound) { result.add(element); } } } catch (Exception e1) { e1.printStackTrace(); } e.setStackTrace(result.toArray(new StackTraceElement[0])); } //The following methods Map Java lines back to their original Umple file / line public UmpleSourceData Mentor_main(){ return new UmpleSourceData().setFileNames("ClassTemplateTest_Generated.ump").setUmpleLines(5).setJavaLines(28).setLengths(1);} } public static class UmpleSourceData { String[] umpleFileNames; Integer[] umpleLines; Integer[] umpleJavaLines; Integer[] umpleLengths; public UmpleSourceData(){ } public String getFileName(int i){ return umpleFileNames[i]; } public Integer getUmpleLine(int i){ return umpleLines[i]; } public Integer getJavaLine(int i){ return umpleJavaLines[i]; } public Integer getLength(int i){ return umpleLengths[i]; } public UmpleSourceData setFileNames(String... filenames){ umpleFileNames = filenames; return this; } public UmpleSourceData setUmpleLines(Integer... umplelines){ umpleLines = umplelines; return this; } public UmpleSourceData setJavaLines(Integer... javalines){ umpleJavaLines = javalines; return this; } public UmpleSourceData setLengths(Integer... lengths){ umpleLengths = lengths; return this; } public int size(){ return umpleFileNames.length; } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 11 "../ClassTemplateTest_Generated5.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Mentor() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 15 "../ClassTemplateTest_Generated5.ump" public static void main(String [] args){ Thread.currentThread().setUncaughtExceptionHandler(new example.Student.UmpleExceptionHandler()); Thread.setDefaultUncaughtExceptionHandler(new example.Student.UmpleExceptionHandler()); /* Class Teacher main */ } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../ClassTemplateTest_Generated2.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Mentor() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 6 "../ClassTemplateTest_Generated2.ump" public void main(String [] args){ } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../ClassTemplateTest_Generated3.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Mentor() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 6 "../ClassTemplateTest_Generated3.ump" public static void main(){ } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../ClassTemplateTest_Generated3.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Mentor() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 6 "../ClassTemplateTest_Generated3.ump" public static void main(){ } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../TestUmpleEnumerations.ump" public class Student { //------------------------ // ENUMERATIONS //------------------------ public enum Status { FullTime, PartTime } public enum Grade { High } public enum RelationshipStatus { Single, Married, Divorced } //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; import java.util.*; // line 3 "../TestUmpleEnumerations_2.ump" public class X { //------------------------ // ENUMERATIONS //------------------------ public enum Colour { Red, Blue, Green } //------------------------ // STATIC VARIABLES //------------------------ public static final int MY_CONST = 100; private static Map<String, X> xsByMyName = new HashMap<String, X>(); //------------------------ // MEMBER VARIABLES //------------------------ //X Attributes private String myName; private String defaultAttr; //X State Machines public enum Sm { s1, s2 } private Sm sm; //------------------------ // CONSTRUCTOR //------------------------ public X(String aDefaultAttr) { defaultAttr = aDefaultAttr; if (!setMyName(aMyName)) { throw new RuntimeException("Cannot create due to duplicate myName. See https://manual.umple.org?RE003ViolationofUniqueness.html"); } setSm(Sm.s1); } //------------------------ // INTERFACE //------------------------ public boolean setMyName(String aMyName) { boolean wasSet = false; String anOldMyName = getMyName(); if (anOldMyName != null && anOldMyName.equals(aMyName)) { return true; } if (hasWithMyName(aMyName)) { return wasSet; } myName = aMyName; wasSet = true; if (anOldMyName != null) { xsByMyName.remove(anOldMyName); } xsByMyName.put(aMyName, this); return wasSet; } public boolean setDefaultAttr(String aDefaultAttr) { boolean wasSet = false; defaultAttr = aDefaultAttr; wasSet = true; return wasSet; } public String getMyName() { return myName; } /* Code from template attribute_GetUnique */ public static X getWithMyName(String aMyName) { return xsByMyName.get(aMyName); } /* Code from template attribute_HasUnique */ public static boolean hasWithMyName(String aMyName) { return getWithMyName(aMyName) != null; } public String getDefaultAttr() { return defaultAttr; } public String getSmFullName() { String answer = sm.toString(); return answer; } public Sm getSm() { return sm; } public boolean goToS2() { boolean wasEventProcessed = false; Sm aSm = sm; switch (aSm) { case s1: setSm(Sm.s2); wasEventProcessed = true; break; default: // Other states do respond to this event } return wasEventProcessed; } private void setSm(Sm aSm) { sm = aSm; } public void delete() { xsByMyName.remove(getMyName()); } public String toString() { return super.toString() + "["+ "myName" + ":" + getMyName()+ "," + "defaultAttr" + ":" + getDefaultAttr()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 6 "../TestUmpleEnumerations_3.ump" public class C1 { //------------------------ // ENUMERATIONS //------------------------ public enum Status { Married, Single, Divorced } public enum Gender { Male, Female } //------------------------ // MEMBER VARIABLES //------------------------ //C1 Attributes private Status status; private Gender gender; //------------------------ // CONSTRUCTOR //------------------------ public C1(Status aStatus, Gender aGender) { status = aStatus; gender = aGender; } //------------------------ // INTERFACE //------------------------ public boolean setStatus(Status aStatus) { boolean wasSet = false; status = aStatus; wasSet = true; return wasSet; } public boolean setGender(Gender aGender) { boolean wasSet = false; gender = aGender; wasSet = true; return wasSet; } public Status getStatus() { return status; } public Gender getGender() { return gender; } public void delete() {} public String toString() { return super.toString() + "["+ "]" + System.getProperties().getProperty("line.separator") + " " + "status" + "=" + (getStatus() != null ? !getStatus().equals(this) ? getStatus().toString().replaceAll(" "," ") : "this" : "null") + System.getProperties().getProperty("line.separator") + " " + "gender" + "=" + (getGender() != null ? !getGender().equals(this) ? getGender().toString().replaceAll(" "," ") : "this" : "null"); } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 11 "../TestUmpleEnumerations_3.ump" public class C2 { //------------------------ // ENUMERATIONS //------------------------ public enum Status { Married, Single, Divorced } public enum Gender { Male, Female } //------------------------ // MEMBER VARIABLES //------------------------ //C2 Attributes private Status status; private Gender gender; //------------------------ // CONSTRUCTOR //------------------------ public C2(Status aStatus, Gender aGender) { status = aStatus; gender = aGender; } //------------------------ // INTERFACE //------------------------ public boolean setStatus(Status aStatus) { boolean wasSet = false; status = aStatus; wasSet = true; return wasSet; } public boolean setGender(Gender aGender) { boolean wasSet = false; gender = aGender; wasSet = true; return wasSet; } public Status getStatus() { return status; } public Gender getGender() { return gender; } public void delete() {} public String toString() { return super.toString() + "["+ "]" + System.getProperties().getProperty("line.separator") + " " + "status" + "=" + (getStatus() != null ? !getStatus().equals(this) ? getStatus().toString().replaceAll(" "," ") : "this" : "null") + System.getProperties().getProperty("line.separator") + " " + "gender" + "=" + (getGender() != null ? !getGender().equals(this) ? getGender().toString().replaceAll(" "," ") : "this" : "null"); } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 5 "../TestUmpleEnumerations_4.ump" public class C1 { //------------------------ // ENUMERATIONS //------------------------ public enum Status { Married, Single, Divorced } //------------------------ // MEMBER VARIABLES //------------------------ //C1 Attributes private Status status; //------------------------ // CONSTRUCTOR //------------------------ public C1(Status aStatus) { status = aStatus; } //------------------------ // INTERFACE //------------------------ public boolean setStatus(Status aStatus) { boolean wasSet = false; status = aStatus; wasSet = true; return wasSet; } public Status getStatus() { return status; } public void delete() {} public String toString() { return super.toString() + "["+ "]" + System.getProperties().getProperty("line.separator") + " " + "status" + "=" + (getStatus() != null ? !getStatus().equals(this) ? getStatus().toString().replaceAll(" "," ") : "this" : "null"); } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 9 "../TestUmpleEnumerations_4.ump" public class C2 { //------------------------ // ENUMERATIONS //------------------------ public enum Status { Married, Single, Divorced } public enum Gender { Male, Female } //------------------------ // MEMBER VARIABLES //------------------------ //C2 Attributes private Gender gender; private Status status; //------------------------ // CONSTRUCTOR //------------------------ public C2(Gender aGender, Status aStatus) { gender = aGender; status = aStatus; } //------------------------ // INTERFACE //------------------------ public boolean setGender(Gender aGender) { boolean wasSet = false; gender = aGender; wasSet = true; return wasSet; } public boolean setStatus(Status aStatus) { boolean wasSet = false; status = aStatus; wasSet = true; return wasSet; } public Gender getGender() { return gender; } public Status getStatus() { return status; } public void delete() {} public String toString() { return super.toString() + "["+ "]" + System.getProperties().getProperty("line.separator") + " " + "gender" + "=" + (getGender() != null ? !getGender().equals(this) ? getGender().toString().replaceAll(" "," ") : "this" : "null") + System.getProperties().getProperty("line.separator") + " " + "status" + "=" + (getStatus() != null ? !getStatus().equals(this) ? getStatus().toString().replaceAll(" "," ") : "this" : "null"); } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 6 "../TestUmpleEnumerations_5.ump" public class X1 { //------------------------ // ENUMERATIONS //------------------------ public enum Month { January, February, March } //------------------------ // MEMBER VARIABLES //------------------------ //X1 Attributes private Month month; //------------------------ // CONSTRUCTOR //------------------------ public X1(Month aMonth) { month = aMonth; } //------------------------ // INTERFACE //------------------------ public boolean setMonth(Month aMonth) { boolean wasSet = false; month = aMonth; wasSet = true; return wasSet; } public Month getMonth() { return month; } public void delete() {} public String toString() { return super.toString() + "["+ "]" + System.getProperties().getProperty("line.separator") + " " + "month" + "=" + (getMonth() != null ? !getMonth().equals(this) ? getMonth().toString().replaceAll(" "," ") : "this" : "null"); } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 10 "../TestUmpleEnumerations_5.ump" public class X2 { //------------------------ // ENUMERATIONS //------------------------ public enum Fruit { Apple, Orange } //------------------------ // MEMBER VARIABLES //------------------------ //X2 Attributes private Fruit t; //------------------------ // CONSTRUCTOR //------------------------ public X2(Fruit aT) { t = aT; } //------------------------ // INTERFACE //------------------------ public boolean setT(Fruit aT) { boolean wasSet = false; t = aT; wasSet = true; return wasSet; } public Fruit getT() { return t; } public void delete() {} public String toString() { return super.toString() + "["+ "]" + System.getProperties().getProperty("line.separator") + " " + "t" + "=" + (getT() != null ? !getT().equals(this) ? getT().toString().replaceAll(" "," ") : "this" : "null"); } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 6 "../TestUmpleEnumerations_6.ump" public class X { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public X() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 1 "../TestUmpleEnumerations_6.ump" public class X2 { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public X2() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 5 "../TestUmpleEnumerations_7.ump" public class X { //------------------------ // ENUMERATIONS //------------------------ public enum Month { Jan, Feb, Mar } //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public X() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 6 "../TestUmpleEnumerations_7.ump" public String displayMonth(Month m){ return(m.toString()) } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 9 "../TestUmpleEnumerations_7.ump" public class Y { //------------------------ // ENUMERATIONS //------------------------ public enum Month { Jan, Feb, Mar } //------------------------ // MEMBER VARIABLES //------------------------ //Y State Machines public enum Sm { s1, s2 } private Sm sm; //------------------------ // CONSTRUCTOR //------------------------ public Y() { setSm(Sm.s1); } //------------------------ // INTERFACE //------------------------ public String getSmFullName() { String answer = sm.toString(); return answer; } public Sm getSm() { return sm; } public boolean goToS2(Month m) { boolean wasEventProcessed = false; Sm aSm = sm; switch (aSm) { case s1: // line 12 "../TestUmpleEnumerations_7.ump" System.out.println(m); setSm(Sm.s2); wasEventProcessed = true; break; default: // Other states do respond to this event } return wasEventProcessed; } private void setSm(Sm aSm) { sm = aSm; } public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 18 "../TestUmpleEnumerations_7.ump" public class Z { //------------------------ // ENUMERATIONS //------------------------ public enum Month { Jan, Feb, Mar } //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Z() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 19 "../TestUmpleEnumerations_7.ump" public Month getBirthMonth(){ return Month.Jan; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 7 "../TestUmpleEnumerations_8.ump" public class A { //------------------------ // ENUMERATIONS //------------------------ public enum Month { O, P, Q } //------------------------ // MEMBER VARIABLES //------------------------ //A Attributes private Month m; private Month p; //------------------------ // CONSTRUCTOR //------------------------ public A(Month aM, Month aP) { m = aM; p = aP; } //------------------------ // INTERFACE //------------------------ public boolean setM(Month aM) { boolean wasSet = false; m = aM; wasSet = true; return wasSet; } public boolean setP(Month aP) { boolean wasSet = false; p = aP; wasSet = true; return wasSet; } public Month getM() { return m; } public Month getP() { return p; } public void delete() {} public String toString() { return super.toString() + "["+ "]" + System.getProperties().getProperty("line.separator") + " " + "m" + "=" + (getM() != null ? !getM().equals(this) ? getM().toString().replaceAll(" "," ") : "this" : "null") + System.getProperties().getProperty("line.separator") + " " + "p" + "=" + (getP() != null ? !getP().equals(this) ? getP().toString().replaceAll(" "," ") : "this" : "null"); } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 2 "../ImmutableNotLazyAttributeConstructor.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //Student Attributes private String number; private String number2; //Helper Variables private boolean canSetNumber2; //------------------------ // CONSTRUCTOR //------------------------ public Student(String aNumber) { number = aNumber; canSetNumber2 = true; } //------------------------ // INTERFACE //------------------------ /* Code from template attribute_SetImmutable */ public boolean setNumber2(String aNumber2) { boolean wasSet = false; if (!canSetNumber2) { return false; } canSetNumber2 = false; number2 = aNumber2; wasSet = true; return wasSet; } public String getNumber() { return number; } public String getNumber2() { return number2; } public void delete() {} public String toString() { return super.toString() + "["+ "number" + ":" + getNumber()+ "," + "number2" + ":" + getNumber2()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "ClassTemplateTest_InternalConstant.ump" public class Student { //------------------------ // STATIC VARIABLES //------------------------ private static final String Name = "XYZ"; //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; import java.util.*; // line 3 "../CascadeDelete.ump" public class B { //------------------------ // MEMBER VARIABLES //------------------------ //B Associations private List<C> myC; //------------------------ // CONSTRUCTOR //------------------------ public B() { myC = new ArrayList<C>(); } //------------------------ // INTERFACE //------------------------ /* Code from template association_GetMany */ public C getMyC(int index) { C aMyC = myC.get(index); return aMyC; } public List<C> getMyC() { List<C> newMyC = Collections.unmodifiableList(myC); return newMyC; } public int numberOfMyC() { int number = myC.size(); return number; } public boolean hasMyC() { boolean has = myC.size() > 0; return has; } public int indexOfMyC(C aMyC) { int index = myC.indexOf(aMyC); return index; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfMyC() { return 0; } /* Code from template association_AddManyToOne */ public C addMyC(D aMyD) { return new C(aMyD, this); } public boolean addMyC(C aMyC) { boolean wasAdded = false; if (myC.contains(aMyC)) { return false; } B existingB = aMyC.getB(); boolean isNewB = existingB != null && !this.equals(existingB); if (isNewB) { aMyC.setB(this); } else { myC.add(aMyC); } wasAdded = true; return wasAdded; } public boolean removeMyC(C aMyC) { boolean wasRemoved = false; //Unable to remove aMyC, as it must always have a b if (!this.equals(aMyC.getB())) { myC.remove(aMyC); wasRemoved = true; } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addMyCAt(C aMyC, int index) { boolean wasAdded = false; if(addMyC(aMyC)) { if(index < 0 ) { index = 0; } if(index > numberOfMyC()) { index = numberOfMyC() - 1; } myC.remove(aMyC); myC.add(index, aMyC); wasAdded = true; } return wasAdded; } public boolean addOrMoveMyCAt(C aMyC, int index) { boolean wasAdded = false; if(myC.contains(aMyC)) { if(index < 0 ) { index = 0; } if(index > numberOfMyC()) { index = numberOfMyC() - 1; } myC.remove(aMyC); myC.add(index, aMyC); wasAdded = true; } else { wasAdded = addMyCAt(aMyC, index); } return wasAdded; } public void delete() { while (myC.size() > 0) { C aMyC = myC.get(myC.size() - 1); aMyC.delete(); myC.remove(aMyC); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 6 "../CascadeDelete.ump" public class C { //------------------------ // MEMBER VARIABLES //------------------------ //C Associations private D myD; private B b; //------------------------ // CONSTRUCTOR //------------------------ public C(D aMyD, B aB) { if (aMyD == null || aMyD.getC() != null) { throw new RuntimeException("Unable to create C due to aMyD. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html"); } myD = aMyD; boolean didAddB = setB(aB); if (!didAddB) { throw new RuntimeException("Unable to create myC due to b. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html"); } } public C(B aB) { myD = new D(this); boolean didAddB = setB(aB); if (!didAddB) { throw new RuntimeException("Unable to create myC due to b. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html"); } } //------------------------ // INTERFACE //------------------------ /* Code from template association_GetOne */ public D getMyD() { return myD; } /* Code from template association_GetOne */ public B getB() { return b; } /* Code from template association_SetOneToMany */ public boolean setB(B aB) { boolean wasSet = false; if (aB == null) { return wasSet; } B existingB = b; b = aB; if (existingB != null && !existingB.equals(aB)) { existingB.removeMyC(this); } b.addMyC(this); wasSet = true; return wasSet; } public void delete() { D existingMyD = myD; myD = null; if (existingMyD != null) { existingMyD.delete(); } B placeholderB = b; this.b = null; if(placeholderB != null) { placeholderB.removeMyC(this); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 1 "../CascadeDelete.ump" public class D { //------------------------ // MEMBER VARIABLES //------------------------ //D Associations private C c; //------------------------ // CONSTRUCTOR //------------------------ public D(C aC) { if (aC == null || aC.getMyD() != null) { throw new RuntimeException("Unable to create D due to aC. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html"); } c = aC; } public D(B aBForC) { c = new C(this, aBForC); } //------------------------ // INTERFACE //------------------------ /* Code from template association_GetOne */ public C getC() { return c; } public void delete() { C existingC = c; c = null; if (existingC != null) { existingC.delete(); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 7 "ClassTemplateTest_StateMachineDoesNotImplementInterface.ump" public class FileLogger implements Logger { //------------------------ // MEMBER VARIABLES //------------------------ //FileLogger Attributes private String fileName; //FileLogger State Machines public enum Status { disconnected, connected } private Status status; //------------------------ // CONSTRUCTOR //------------------------ public FileLogger(String aFileName) { fileName = aFileName; setStatus(Status.disconnected); } //------------------------ // INTERFACE //------------------------ public String getStatusFullName() { String answer = status.toString(); return answer; } public Status getStatus() { return status; } public boolean attemptConnection() { boolean wasEventProcessed = false; Status aStatus = status; switch (aStatus) { case disconnected: setStatus(Status.connected); wasEventProcessed = true; break; default: // Other states do respond to this event } return wasEventProcessed; } public boolean signalDisconnect() { boolean wasEventProcessed = false; Status aStatus = status; switch (aStatus) { case connected: setStatus(Status.disconnected); wasEventProcessed = true; break; default: // Other states do respond to this event } return wasEventProcessed; } public boolean communicate(String message) { boolean wasEventProcessed = false; Status aStatus = status; switch (aStatus) { case connected: setStatus(Status.connected); wasEventProcessed = true; break; default: // Other states do respond to this event } return wasEventProcessed; } private void setStatus(Status aStatus) { status = aStatus; } public void delete() {} @Override public boolean connect(){ return false; } @Override public boolean disconnect(){ return false; } @Override public boolean write(String data){ return false; } public String toString() { return super.toString() + "["+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "ClassTemplateTest_CodeInjectionsComments.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 3 "ClassTemplateTest_CodeInjectionsComments.ump" public String foo(int a){ // line 25 "ClassTemplateTest_CodeInjectionsComments.ump" System.out.println("Starting foo with argument: " + a); // END OF UMPLE BEFORE INJECTION if(a < 0) { /* { */ // line 29 "ClassTemplateTest_CodeInjectionsComments.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 0; } else if(a == 1) { // foo() // line 29 "ClassTemplateTest_CodeInjectionsComments.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return -1; } else { // { // line 29 "ClassTemplateTest_CodeInjectionsComments.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 4; } for(int i = 0; i < a; i++) { // TODO: call foo() if(i == a/4) { // line 29 "ClassTemplateTest_CodeInjectionsComments.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return a; } } // line 29 "ClassTemplateTest_CodeInjectionsComments.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 4; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package enumerations; import java.util.*; // line 3 "../TestUmpleEnumerations_innerQualified_1.ump" public class Driver { //------------------------ // MEMBER VARIABLES //------------------------ //Driver Associations private List<DriverSchedule> driverSchedules; //------------------------ // CONSTRUCTOR //------------------------ public Driver() { driverSchedules = new ArrayList<DriverSchedule>(); } //------------------------ // INTERFACE //------------------------ /* Code from template association_GetMany */ public DriverSchedule getDriverSchedule(int index) { DriverSchedule aDriverSchedule = driverSchedules.get(index); return aDriverSchedule; } public List<DriverSchedule> getDriverSchedules() { List<DriverSchedule> newDriverSchedules = Collections.unmodifiableList(driverSchedules); return newDriverSchedules; } public int numberOfDriverSchedules() { int number = driverSchedules.size(); return number; } public boolean hasDriverSchedules() { boolean has = driverSchedules.size() > 0; return has; } public int indexOfDriverSchedule(DriverSchedule aDriverSchedule) { int index = driverSchedules.indexOf(aDriverSchedule); return index; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfDriverSchedules() { return 0; } /* Code from template association_AddManyToOne */ public DriverSchedule addDriverSchedule(DriverSchedule.Shift aShift, DriverSchedule.Status aStatus) { return new DriverSchedule(aShift, aStatus, this); } public boolean addDriverSchedule(DriverSchedule aDriverSchedule) { boolean wasAdded = false; if (driverSchedules.contains(aDriverSchedule)) { return false; } Driver existingDriver = aDriverSchedule.getDriver(); boolean isNewDriver = existingDriver != null && !this.equals(existingDriver); if (isNewDriver) { aDriverSchedule.setDriver(this); } else { driverSchedules.add(aDriverSchedule); } wasAdded = true; return wasAdded; } public boolean removeDriverSchedule(DriverSchedule aDriverSchedule) { boolean wasRemoved = false; //Unable to remove aDriverSchedule, as it must always have a driver if (!this.equals(aDriverSchedule.getDriver())) { driverSchedules.remove(aDriverSchedule); wasRemoved = true; } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addDriverScheduleAt(DriverSchedule aDriverSchedule, int index) { boolean wasAdded = false; if(addDriverSchedule(aDriverSchedule)) { if(index < 0 ) { index = 0; } if(index > numberOfDriverSchedules()) { index = numberOfDriverSchedules() - 1; } driverSchedules.remove(aDriverSchedule); driverSchedules.add(index, aDriverSchedule); wasAdded = true; } return wasAdded; } public boolean addOrMoveDriverScheduleAt(DriverSchedule aDriverSchedule, int index) { boolean wasAdded = false; if(driverSchedules.contains(aDriverSchedule)) { if(index < 0 ) { index = 0; } if(index > numberOfDriverSchedules()) { index = numberOfDriverSchedules() - 1; } driverSchedules.remove(aDriverSchedule); driverSchedules.add(index, aDriverSchedule); wasAdded = true; } else { wasAdded = addDriverScheduleAt(aDriverSchedule, index); } return wasAdded; } public void delete() { for(int i=driverSchedules.size(); i > 0; i--) { DriverSchedule aDriverSchedule = driverSchedules.get(i - 1); aDriverSchedule.delete(); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 4 "../ClassTemplateTest_Java.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Mentor() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "ClassTemplateTest_CodeInjectionsBasic.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 3 "ClassTemplateTest_CodeInjectionsBasic.ump" public String foo(int a){ // line 17 "ClassTemplateTest_CodeInjectionsBasic.ump" System.out.println("Starting foo with argument: " + a); // END OF UMPLE BEFORE INJECTION if(a < 0) { // line 21 "ClassTemplateTest_CodeInjectionsBasic.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 0; } for(int i = 0; i < a; i++) { if(i == a/4) { // line 21 "ClassTemplateTest_CodeInjectionsBasic.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return a; } } // line 21 "ClassTemplateTest_CodeInjectionsBasic.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 4; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "ClassTemplateTest_CodeInjectionsParametersMulti.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 3 "ClassTemplateTest_CodeInjectionsParametersMulti.ump" public String foo(int a){ // line 26 "ClassTemplateTest_CodeInjectionsParametersMulti.ump" System.out.println("Starting foo..."); // END OF UMPLE BEFORE INJECTION // line 38 "ClassTemplateTest_CodeInjectionsParametersMulti.ump" System.out.println("Starting execution..."); // END OF UMPLE BEFORE INJECTION if(a < 0) { return 4; } return 3; } // line 11 "ClassTemplateTest_CodeInjectionsParametersMulti.ump" public String foo(int a, String b){ // line 26 "ClassTemplateTest_CodeInjectionsParametersMulti.ump" System.out.println("Starting foo..."); // END OF UMPLE BEFORE INJECTION if(a > 0 && "".equals(b)) { // line 30 "ClassTemplateTest_CodeInjectionsParametersMulti.ump" System.out.println("Returning from foo, a: " + a ", b: " + b); // END OF UMPLE AFTER INJECTION return 3; } // line 30 "ClassTemplateTest_CodeInjectionsParametersMulti.ump" System.out.println("Returning from foo, a: " + a ", b: " + b); // END OF UMPLE AFTER INJECTION return 1; } // line 18 "ClassTemplateTest_CodeInjectionsParametersMulti.ump" public String bar(){ // line 34 "ClassTemplateTest_CodeInjectionsParametersMulti.ump" // TODO: fix asap // END OF UMPLE BEFORE INJECTION // line 38 "ClassTemplateTest_CodeInjectionsParametersMulti.ump" System.out.println("Starting execution..."); // END OF UMPLE BEFORE INJECTION int a = 4; if(a == 3) return 2; return 1; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "ClassTemplateTest_CodeInjectionsNoBraces.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 3 "ClassTemplateTest_CodeInjectionsNoBraces.ump" public String foo(int a){ // line 18 "ClassTemplateTest_CodeInjectionsNoBraces.ump" System.out.println("Starting foo with argument: " + a); // END OF UMPLE BEFORE INJECTION if(a < 0) { // line 22 "ClassTemplateTest_CodeInjectionsNoBraces.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 0; } else if(a == 1) { // line 22 "ClassTemplateTest_CodeInjectionsNoBraces.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return -1; } else { // line 22 "ClassTemplateTest_CodeInjectionsNoBraces.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 4; } for(int i = 0; i < a; i++) if(i == a/4) { // line 22 "ClassTemplateTest_CodeInjectionsNoBraces.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return a; } // line 22 "ClassTemplateTest_CodeInjectionsNoBraces.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 4; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example.one; import example.two.*; // line 3 "../../ClassTemplateTest_Import.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //Mentor Attributes private String name; //Mentor Associations private Student student; //------------------------ // CONSTRUCTOR //------------------------ public Mentor(String aName) { name = aName; } //------------------------ // INTERFACE //------------------------ public boolean setName(String aName) { boolean wasSet = false; name = aName; wasSet = true; return wasSet; } public String getName() { return name; } /* Code from template association_GetOne */ public Student getStudent() { return student; } public boolean hasStudent() { boolean has = student != null; return has; } /* Code from template association_SetOptionalOneToMandatoryMany */ public boolean setStudent(Student aStudent) { // // This source of this source generation is association_SetOptionalOneToMandatoryMany.jet // This set file assumes the generation of a maximumNumberOfXXX method does not exist because // it's not required (No upper bound) // boolean wasSet = false; Student existingStudent = student; if (existingStudent == null) { if (aStudent != null) { if (aStudent.addMentor(this)) { existingStudent = aStudent; wasSet = true; } } } else if (existingStudent != null) { if (aStudent == null) { if (existingStudent.minimumNumberOfMentors() < existingStudent.numberOfMentors()) { existingStudent.removeMentor(this); existingStudent = aStudent; // aStudent == null wasSet = true; } } else { if (existingStudent.minimumNumberOfMentors() < existingStudent.numberOfMentors()) { existingStudent.removeMentor(this); aStudent.addMentor(this); existingStudent = aStudent; wasSet = true; } } } if (wasSet) { student = existingStudent; } return wasSet; } public void delete() { if (student != null) { if (student.numberOfMentors() <= 1) { student.delete(); } else { Student placeholderStudent = student; this.student = null; placeholderStudent.removeMentor(this); } } } public String toString() { return super.toString() + "["+ "name" + ":" + getName()+ "]" + System.getProperties().getProperty("line.separator") + " " + "student = "+(getStudent()!=null?Integer.toHexString(System.identityHashCode(getStudent())):"null"); } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example.two; import java.util.*; import example.one.*; import example.three.*; // line 11 "../../ClassTemplateTest_Import.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //Student Attributes private String number; //Student Associations private List<Mentor> mentors; private List<Course> courses; //------------------------ // CONSTRUCTOR //------------------------ public Student(String aNumber, Mentor... allMentors) { number = aNumber; mentors = new ArrayList<Mentor>(); boolean didAddMentors = setMentors(allMentors); if (!didAddMentors) { throw new RuntimeException("Unable to create Student, must have at least 1 mentors. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html"); } courses = new ArrayList<Course>(); } //------------------------ // INTERFACE //------------------------ public boolean setNumber(String aNumber) { boolean wasSet = false; number = aNumber; wasSet = true; return wasSet; } 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_GetMany */ public Course getCourse(int index) { Course aCourse = courses.get(index); return aCourse; } public List<Course> getCourses() { List<Course> newCourses = Collections.unmodifiableList(courses); return newCourses; } public int numberOfCourses() { int number = courses.size(); return number; } public boolean hasCourses() { boolean has = courses.size() > 0; return has; } public int indexOfCourse(Course aCourse) { int index = courses.indexOf(aCourse); return index; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfMentors() { return 1; } /* Code from template association_AddMNToOptionalOne */ public boolean addMentor(Mentor aMentor) { boolean wasAdded = false; if (mentors.contains(aMentor)) { return false; } Student existingStudent = aMentor.getStudent(); if (existingStudent != null && existingStudent.numberOfMentors() <= minimumNumberOfMentors()) { return wasAdded; } else if (existingStudent != null) { existingStudent.mentors.remove(aMentor); } mentors.add(aMentor); setStudent(aMentor,this); wasAdded = true; return wasAdded; } public boolean removeMentor(Mentor aMentor) { boolean wasRemoved = false; if (mentors.contains(aMentor) && numberOfMentors() > minimumNumberOfMentors()) { mentors.remove(aMentor); setStudent(aMentor,null); wasRemoved = true; } return wasRemoved; } /* Code from template association_SetMNToOptionalOne */ public boolean setMentors(Mentor... newMentors) { boolean wasSet = false; if (newMentors.length < minimumNumberOfMentors()) { return wasSet; } ArrayList<Mentor> checkNewMentors = new ArrayList<Mentor>(); HashMap<Student,Integer> studentToNewMentors = new HashMap<Student,Integer>(); for (Mentor aMentor : newMentors) { if (checkNewMentors.contains(aMentor)) { return wasSet; } else if (aMentor.getStudent() != null && !this.equals(aMentor.getStudent())) { Student existingStudent = aMentor.getStudent(); if (!studentToNewMentors.containsKey(existingStudent)) { studentToNewMentors.put(existingStudent, Integer.valueOf(existingStudent.numberOfMentors())); } Integer currentCount = studentToNewMentors.get(existingStudent); int nextCount = currentCount - 1; if (nextCount < 1) { return wasSet; } studentToNewMentors.put(existingStudent, Integer.valueOf(nextCount)); } checkNewMentors.add(aMentor); } mentors.removeAll(checkNewMentors); for (Mentor orphan : mentors) { setStudent(orphan, null); } mentors.clear(); for (Mentor aMentor : newMentors) { if (aMentor.getStudent() != null) { aMentor.getStudent().mentors.remove(aMentor); } setStudent(aMentor, this); mentors.add(aMentor); } wasSet = true; return wasSet; } /* Code from template association_GetPrivate */ private void setStudent(Mentor aMentor, Student aStudent) { try { java.lang.reflect.Field mentorField = aMentor.getClass().getDeclaredField("student"); mentorField.setAccessible(true); mentorField.set(aMentor, aStudent); } catch (Exception e) { throw new RuntimeException("Issue internally setting aStudent to aMentor", e); } } /* Code from template association_AddIndexControlFunctions */ public boolean addMentorAt(Mentor aMentor, int index) { boolean wasAdded = false; if(addMentor(aMentor)) { if(index < 0 ) { index = 0; } if(index > numberOfMentors()) { index = numberOfMentors() - 1; } mentors.remove(aMentor); mentors.add(index, aMentor); wasAdded = true; } return wasAdded; } public boolean addOrMoveMentorAt(Mentor aMentor, int index) { boolean wasAdded = false; if(mentors.contains(aMentor)) { if(index < 0 ) { index = 0; } if(index > numberOfMentors()) { index = numberOfMentors() - 1; } mentors.remove(aMentor); mentors.add(index, aMentor); wasAdded = true; } else { wasAdded = addMentorAt(aMentor, index); } return wasAdded; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfCourses() { return 0; } /* Code from template association_AddManyToManyMethod */ public boolean addCourse(Course aCourse) { boolean wasAdded = false; if (courses.contains(aCourse)) { return false; } courses.add(aCourse); if (aCourse.indexOfStudent(this) != -1) { wasAdded = true; } else { wasAdded = aCourse.addStudent(this); if (!wasAdded) { courses.remove(aCourse); } } return wasAdded; } /* Code from template association_RemoveMany */ public boolean removeCourse(Course aCourse) { boolean wasRemoved = false; if (!courses.contains(aCourse)) { return wasRemoved; } int oldIndex = courses.indexOf(aCourse); courses.remove(oldIndex); if (aCourse.indexOfStudent(this) == -1) { wasRemoved = true; } else { wasRemoved = aCourse.removeStudent(this); if (!wasRemoved) { courses.add(oldIndex,aCourse); } } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addCourseAt(Course aCourse, int index) { boolean wasAdded = false; if(addCourse(aCourse)) { if(index < 0 ) { index = 0; } if(index > numberOfCourses()) { index = numberOfCourses() - 1; } courses.remove(aCourse); courses.add(index, aCourse); wasAdded = true; } return wasAdded; } public boolean addOrMoveCourseAt(Course aCourse, int index) { boolean wasAdded = false; if(courses.contains(aCourse)) { if(index < 0 ) { index = 0; } if(index > numberOfCourses()) { index = numberOfCourses() - 1; } courses.remove(aCourse); courses.add(index, aCourse); wasAdded = true; } else { wasAdded = addCourseAt(aCourse, index); } return wasAdded; } public void delete() { for(Mentor aMentor : mentors) { setStudent(aMentor,null); } mentors.clear(); ArrayList<Course> copyOfCourses = new ArrayList<Course>(courses); courses.clear(); for(Course aCourse : copyOfCourses) { aCourse.removeStudent(this); } } public String toString() { return super.toString() + "["+ "number" + ":" + getNumber()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example.three; import java.util.*; import example.two.*; // line 18 "../../ClassTemplateTest_Import.ump" public class Course { //------------------------ // MEMBER VARIABLES //------------------------ //Course Associations private List<Student> students; //------------------------ // CONSTRUCTOR //------------------------ public Course() { students = new ArrayList<Student>(); } //------------------------ // INTERFACE //------------------------ /* Code from template association_GetMany */ public Student getStudent(int index) { Student aStudent = students.get(index); return aStudent; } public List<Student> getStudents() { List<Student> newStudents = Collections.unmodifiableList(students); return newStudents; } public int numberOfStudents() { int number = students.size(); return number; } public boolean hasStudents() { boolean has = students.size() > 0; return has; } public int indexOfStudent(Student aStudent) { int index = students.indexOf(aStudent); return index; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfStudents() { return 0; } /* Code from template association_AddManyToManyMethod */ public boolean addStudent(Student aStudent) { boolean wasAdded = false; if (students.contains(aStudent)) { return false; } students.add(aStudent); if (aStudent.indexOfCourse(this) != -1) { wasAdded = true; } else { wasAdded = aStudent.addCourse(this); if (!wasAdded) { students.remove(aStudent); } } return wasAdded; } /* Code from template association_RemoveMany */ public boolean removeStudent(Student aStudent) { boolean wasRemoved = false; if (!students.contains(aStudent)) { return wasRemoved; } int oldIndex = students.indexOf(aStudent); students.remove(oldIndex); if (aStudent.indexOfCourse(this) == -1) { wasRemoved = true; } else { wasRemoved = aStudent.removeCourse(this); if (!wasRemoved) { students.add(oldIndex,aStudent); } } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addStudentAt(Student aStudent, int index) { boolean wasAdded = false; if(addStudent(aStudent)) { if(index < 0 ) { index = 0; } if(index > numberOfStudents()) { index = numberOfStudents() - 1; } students.remove(aStudent); students.add(index, aStudent); wasAdded = true; } return wasAdded; } public boolean addOrMoveStudentAt(Student aStudent, int index) { boolean wasAdded = false; if(students.contains(aStudent)) { if(index < 0 ) { index = 0; } if(index > numberOfStudents()) { index = numberOfStudents() - 1; } students.remove(aStudent); students.add(index, aStudent); wasAdded = true; } else { wasAdded = addStudentAt(aStudent, index); } return wasAdded; } public void delete() { ArrayList<Student> copyOfStudents = new ArrayList<Student>(students); students.clear(); for(Student aStudent : copyOfStudents) { aStudent.removeCourse(this); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "ClassTemplateTest_CodeInjectionsSingleLine.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 3 "ClassTemplateTest_CodeInjectionsSingleLine.ump" public String foo(int a){ // line 16 "ClassTemplateTest_CodeInjectionsSingleLine.ump" System.out.println("Starting foo with argument: " + a); // END OF UMPLE BEFORE INJECTION if(a < 0) { // line 20 "ClassTemplateTest_CodeInjectionsSingleLine.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 0; } else if(a == 1) { // line 20 "ClassTemplateTest_CodeInjectionsSingleLine.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return -1; } else { // line 20 "ClassTemplateTest_CodeInjectionsSingleLine.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 4; } for(int i = 0; i < a; i++) { // TODO: call foo() if(i == a/4) { // line 20 "ClassTemplateTest_CodeInjectionsSingleLine.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return a; } } // line 20 "ClassTemplateTest_CodeInjectionsSingleLine.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 4; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../ClassTemplateTest_Methods.ump" public class CodeTranslator { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public CodeTranslator() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 6 "../ClassTemplateTest_Methods.ump" public String translate(String id, Attribute attribute){ return "1"; } // line 9 "../ClassTemplateTest_Methods.ump" public String translate(String id, AssociationVariable associationVariable){ return "1"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 7 "ClassTemplateTest_StateMachineImplementsInterface.ump" public class FileLogger implements Logger { //------------------------ // MEMBER VARIABLES //------------------------ //FileLogger Attributes private String fileName; //FileLogger State Machines public enum Status { disconnected, connected } private Status status; //------------------------ // CONSTRUCTOR //------------------------ public FileLogger(String aFileName) { fileName = aFileName; setStatus(Status.disconnected); } //------------------------ // INTERFACE //------------------------ public String getStatusFullName() { String answer = status.toString(); return answer; } public Status getStatus() { return status; } @Override public boolean connect() { boolean wasEventProcessed = false; Status aStatus = status; switch (aStatus) { case disconnected: setStatus(Status.connected); wasEventProcessed = true; break; default: // Other states do respond to this event } return wasEventProcessed; } @Override public boolean disconnect() { boolean wasEventProcessed = false; Status aStatus = status; switch (aStatus) { case connected: setStatus(Status.disconnected); wasEventProcessed = true; break; default: // Other states do respond to this event } return wasEventProcessed; } @Override public boolean write(String data) { boolean wasEventProcessed = false; Status aStatus = status; switch (aStatus) { case connected: setStatus(Status.connected); wasEventProcessed = true; break; default: // Other states do respond to this event } return wasEventProcessed; } private void setStatus(Status aStatus) { status = aStatus; } public void delete() {} public String toString() { return super.toString() + "["+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "ClassTemplateTest_AttributeComments.ump" public class Student { //------------------------ // STATIC VARIABLES //------------------------ /** * Comment for a const attribute */ public static final String a = ""; //------------------------ // MEMBER VARIABLES //------------------------ //Student Attributes /** * Comment for an internal attribute */ private String b; //------------------------ // CONSTRUCTOR //------------------------ public Student(String aB) { b = aB; } //------------------------ // INTERFACE //------------------------ /** * Comment for a derived attribute */ public int getC() { return 1+1; } public void delete() {} public String toString() { return super.toString() + "["+ "c" + ":" + getC()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "ClassTemplateTest_CodeInjectionsBasicOnOneLine.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} // line 3 "ClassTemplateTest_CodeInjectionsBasicOnOneLine.ump" public String foo(int a){ // line 16 "ClassTemplateTest_CodeInjectionsBasicOnOneLine.ump" System.out.println("Starting foo with argument: " + a); // END OF UMPLE BEFORE INJECTION if(a < 0) { // line 18 "ClassTemplateTest_CodeInjectionsBasicOnOneLine.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 0; } for(int i = 0; i < a; i++) { if(i == a/4) { // line 18 "ClassTemplateTest_CodeInjectionsBasicOnOneLine.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return a; } } // line 18 "ClassTemplateTest_CodeInjectionsBasicOnOneLine.ump" System.out.println("Returning from foo!"); // END OF UMPLE AFTER INJECTION return 4; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 7 "ClassTemplateTest_StateMachineImplementsPartialInterface.ump" public class FileLogger implements Logger { //------------------------ // MEMBER VARIABLES //------------------------ //FileLogger Attributes private String fileName; //FileLogger State Machines public enum Status { disconnected, connected } private Status status; //------------------------ // CONSTRUCTOR //------------------------ public FileLogger(String aFileName) { fileName = aFileName; setStatus(Status.disconnected); } //------------------------ // INTERFACE //------------------------ public String getStatusFullName() { String answer = status.toString(); return answer; } public Status getStatus() { return status; } @Override public boolean connect() { boolean wasEventProcessed = false; Status aStatus = status; switch (aStatus) { case disconnected: setStatus(Status.connected); wasEventProcessed = true; break; default: // Other states do respond to this event } return wasEventProcessed; } @Override public boolean disconnect() { boolean wasEventProcessed = false; Status aStatus = status; switch (aStatus) { case connected: setStatus(Status.disconnected); wasEventProcessed = true; break; default: // Other states do respond to this event } return wasEventProcessed; } private void setStatus(Status aStatus) { status = aStatus; } public void delete() {} @Override public boolean write(String data){ return false; } public String toString() { return super.toString() + "["+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 9 "../ClassTemplateTest_ImplementedMethods.ump" public class CodeTranslator implements ICodeTranslator { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public CodeTranslator() {} //------------------------ // INTERFACE //------------------------ public void delete() {} @Override public String translate(String id, Attribute attribute){ return ""; } @Override public String translate(String id, AssociationVariable associationVariable){ return ""; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 5 "ClassTemplateTest_VoidImplementedMethod.ump" public class ClientConsole implements ChatIF { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public ClientConsole() {} //------------------------ // INTERFACE //------------------------ public void delete() {} @Override public void display(){ return ; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; import java.sql.Date; import java.sql.Time; import java.util.*; // line 4 "../ClassTemplateTest_Attributes.ump" public class Mentor { //------------------------ // STATIC VARIABLES //------------------------ public static final int MAX = 100; public static final int MIN = -99; public static final String HELLO = "Hello"; private static int nextX = 1; private static Map<String, Mentor> mentorsById = new HashMap<String, Mentor>(); //------------------------ // MEMBER VARIABLES //------------------------ //Mentor Attributes private String str; private String str2; private String someName; private double lDoub; private boolean lBool; private String name; private Date d; private Time t; private int i; private String id; private String p; private String q; private String r; private String s; private Date tt; private Time u; private Date v; private Time w; //Autounique Attributes private int x; //Helper Variables private boolean canSetStr2; //------------------------ // CONSTRUCTOR //------------------------ public Mentor(String aStr, Date aD, int aI, String aId) { str = aStr; canSetStr2 = true; someName = null; lDoub = 0; lBool = false; name = "Johannes"; d = aD; t = new Time(); i = aI; resetP(); q = "chicken"; resetR(); s = "123"; tt = Date.valueOf("1978-12-25"); u = Time.valueOf("12:13:14"); resetV(); resetW(); x = nextX++; if (!setId(aId)) { throw new RuntimeException("Cannot create due to duplicate id. See https://manual.umple.org?RE003ViolationofUniqueness.html"); } } //------------------------ // INTERFACE //------------------------ /* Code from template attribute_SetImmutable */ public boolean setStr2(String aStr2) { boolean wasSet = false; if (!canSetStr2) { return false; } canSetStr2 = false; str2 = aStr2; wasSet = true; return wasSet; } public boolean setSomeName(String aSomeName) { boolean wasSet = false; someName = aSomeName; wasSet = true; return wasSet; } public boolean setLDoub(double aLDoub) { boolean wasSet = false; lDoub = aLDoub; wasSet = true; return wasSet; } public boolean setLBool(boolean aLBool) { boolean wasSet = false; lBool = aLBool; wasSet = true; return wasSet; } public boolean setName(String aName) { boolean wasSet = false; name = aName; wasSet = true; return wasSet; } public boolean setD(Date aD) { boolean wasSet = false; d = aD; wasSet = true; return wasSet; } public boolean setI(int aI) { boolean wasSet = false; i = aI; wasSet = true; return wasSet; } public boolean setId(String aId) { boolean wasSet = false; String anOldId = getId(); if (anOldId != null && anOldId.equals(aId)) { return true; } if (hasWithId(aId)) { return wasSet; } id = aId; wasSet = true; if (anOldId != null) { mentorsById.remove(anOldId); } mentorsById.put(aId, this); return wasSet; } /* Code from template attribute_SetDefaulted */ public boolean setP(String aP) { boolean wasSet = false; p = aP; wasSet = true; return wasSet; } public boolean resetP() { boolean wasReset = false; p = getDefaultP(); wasReset = true; return wasReset; } public boolean setQ(String aQ) { boolean wasSet = false; q = aQ; wasSet = true; return wasSet; } /* Code from template attribute_SetDefaulted */ public boolean setR(String aR) { boolean wasSet = false; r = aR; wasSet = true; return wasSet; } public boolean resetR() { boolean wasReset = false; r = getDefaultR(); wasReset = true; return wasReset; } public boolean setTt(Date aTt) { boolean wasSet = false; tt = aTt; wasSet = true; return wasSet; } public boolean setU(Time aU) { boolean wasSet = false; u = aU; wasSet = true; return wasSet; } /* Code from template attribute_SetDefaulted */ public boolean setV(Date aV) { boolean wasSet = false; v = aV; wasSet = true; return wasSet; } public boolean resetV() { boolean wasReset = false; v = getDefaultV(); wasReset = true; return wasReset; } /* Code from template attribute_SetDefaulted */ public boolean setW(Time aW) { boolean wasSet = false; w = aW; wasSet = true; return wasSet; } public boolean resetW() { boolean wasReset = false; w = getDefaultW(); wasReset = true; return wasReset; } public String getStr() { return str; } public String getStr2() { return str2; } public String getSomeName() { return someName; } public double getLDoub() { return lDoub; } public boolean getLBool() { return lBool; } public String getName() { return name; } public Date getD() { return d; } public int getI() { return i; } public int getDerivedTwiceI() { return i*2; } public String getId() { return id; } /* Code from template attribute_GetUnique */ public static Mentor getWithId(String aId) { return mentorsById.get(aId); } /* Code from template attribute_HasUnique */ public static boolean hasWithId(String aId) { return getWithId(aId) != null; } public String getP() { return p; } /* Code from template attribute_GetDefaulted */ public String getDefaultP() { return "robot"; } public String getQ() { return q; } public String getR() { return r; } /* Code from template attribute_GetDefaulted */ public String getDefaultR() { return ""; } public String getS() { return s; } public Date getTt() { return tt; } public Time getU() { return u; } public Date getV() { return v; } /* Code from template attribute_GetDefaulted */ public Date getDefaultV() { return Date.valueOf("1978-12-26"); } public Time getW() { return w; } /* Code from template attribute_GetDefaulted */ public Time getDefaultW() { return Time.valueOf("12:59:59"); } public int getX() { return x; } /* Code from template attribute_IsBoolean */ public boolean isLBool() { return lBool; } public void delete() { mentorsById.remove(getId()); } public String toString() { return super.toString() + "["+ "x" + ":" + getX()+ "," + "str" + ":" + getStr()+ "," + "str2" + ":" + getStr2()+ "," + "someName" + ":" + getSomeName()+ "," + "lDoub" + ":" + getLDoub()+ "," + "lBool" + ":" + getLBool()+ "," + "name" + ":" + getName()+ "," + "i" + ":" + getI()+ "," + "derivedTwiceI" + ":" + getDerivedTwiceI()+ "," + "id" + ":" + getId()+ "," + "p" + ":" + getP()+ "," + "q" + ":" + getQ()+ "," + "r" + ":" + getR()+ "," + "s" + ":" + getS()+ "]" + System.getProperties().getProperty("line.separator") + " " + "d" + "=" + (getD() != null ? !getD().equals(this) ? getD().toString().replaceAll(" "," ") : "this" : "null") + System.getProperties().getProperty("line.separator") + " " + "tt" + "=" + (getTt() != null ? !getTt().equals(this) ? getTt().toString().replaceAll(" "," ") : "this" : "null") + System.getProperties().getProperty("line.separator") + " " + "u" + "=" + (getU() != null ? !getU().equals(this) ? getU().toString().replaceAll(" "," ") : "this" : "null") + System.getProperties().getProperty("line.separator") + " " + "v" + "=" + (getV() != null ? !getV().equals(this) ? getV().toString().replaceAll(" "," ") : "this" : "null") + System.getProperties().getProperty("line.separator") + " " + "w" + "=" + (getW() != null ? !getW().equals(this) ? getW().toString().replaceAll(" "," ") : "this" : "null"); } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ import java.util.*; // line 1 "ClassTemplateTest_AbstractClassAvoidingInstantiation.ump" public class Teacher { //------------------------ // MEMBER VARIABLES //------------------------ //Teacher Associations private List<Person> myStudents; //------------------------ // CONSTRUCTOR //------------------------ public Teacher() { myStudents = new ArrayList<Person>(); } //------------------------ // INTERFACE //------------------------ /* Code from template association_GetMany */ public Person getMyStudent(int index) { Person aMyStudent = myStudents.get(index); return aMyStudent; } public List<Person> getMyStudents() { List<Person> newMyStudents = Collections.unmodifiableList(myStudents); return newMyStudents; } public int numberOfMyStudents() { int number = myStudents.size(); return number; } public boolean hasMyStudents() { boolean has = myStudents.size() > 0; return has; } public int indexOfMyStudent(Person aMyStudent) { int index = myStudents.indexOf(aMyStudent); return index; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfMyStudents() { return 0; } /* Code from template association_AddManyToOne */ public boolean addMyStudent(Person aMyStudent) { boolean wasAdded = false; if (myStudents.contains(aMyStudent)) { return false; } Teacher existingTeacher = aMyStudent.getTeacher(); boolean isNewTeacher = existingTeacher != null && !this.equals(existingTeacher); if (isNewTeacher) { aMyStudent.setTeacher(this); } else { myStudents.add(aMyStudent); } wasAdded = true; return wasAdded; } public boolean removeMyStudent(Person aMyStudent) { boolean wasRemoved = false; //Unable to remove aMyStudent, as it must always have a teacher if (!this.equals(aMyStudent.getTeacher())) { myStudents.remove(aMyStudent); wasRemoved = true; } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addMyStudentAt(Person aMyStudent, int index) { boolean wasAdded = false; if(addMyStudent(aMyStudent)) { if(index < 0 ) { index = 0; } if(index > numberOfMyStudents()) { index = numberOfMyStudents() - 1; } myStudents.remove(aMyStudent); myStudents.add(index, aMyStudent); wasAdded = true; } return wasAdded; } public boolean addOrMoveMyStudentAt(Person aMyStudent, int index) { boolean wasAdded = false; if(myStudents.contains(aMyStudent)) { if(index < 0 ) { index = 0; } if(index > numberOfMyStudents()) { index = numberOfMyStudents() - 1; } myStudents.remove(aMyStudent); myStudents.add(index, aMyStudent); wasAdded = true; } else { wasAdded = addMyStudentAt(aMyStudent, index); } return wasAdded; } public void delete() { for(int i=myStudents.size(); i > 0; i--) { Person aMyStudent = myStudents.get(i - 1); aMyStudent.delete(); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ import java.util.*; // line 1 "ClassTemplateTest_MultivaluedAttributesAssignment.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //Foo Attributes private List<String> someStrings; private List<Integer> numbers; private List<Token> objects; //------------------------ // CONSTRUCTOR //------------------------ public Foo() { someStrings = new ArrayList<String>(); someStrings.add("a"); someStrings.add("b"); someStrings.add("c"); numbers = new ArrayList<Integer>(); numbers.add(1); numbers.add(2); numbers.add(3); numbers.add(10); objects = new ArrayList<Token>(); objects.add(new Token("first")); objects.add(new Token("second")); } //------------------------ // INTERFACE //------------------------ /* Code from template attribute_SetMany */ public boolean addSomeString(String aSomeString) { boolean wasAdded = false; wasAdded = someStrings.add(aSomeString); return wasAdded; } public boolean removeSomeString(String aSomeString) { boolean wasRemoved = false; wasRemoved = someStrings.remove(aSomeString); return wasRemoved; } /* Code from template attribute_SetMany */ public boolean addNumber(Integer aNumber) { boolean wasAdded = false; wasAdded = numbers.add(aNumber); return wasAdded; } public boolean removeNumber(Integer aNumber) { boolean wasRemoved = false; wasRemoved = numbers.remove(aNumber); return wasRemoved; } /* Code from template attribute_SetMany */ public boolean addObject(Token aObject) { boolean wasAdded = false; wasAdded = objects.add(aObject); return wasAdded; } public boolean removeObject(Token aObject) { boolean wasRemoved = false; wasRemoved = objects.remove(aObject); return wasRemoved; } /* Code from template attribute_GetMany */ public String getSomeString(int index) { String aSomeString = someStrings.get(index); return aSomeString; } public String[] getSomeStrings() { String[] newSomeStrings = someStrings.toArray(new String[someStrings.size()]); return newSomeStrings; } public int numberOfSomeStrings() { int number = someStrings.size(); return number; } public boolean hasSomeStrings() { boolean has = someStrings.size() > 0; return has; } public int indexOfSomeString(String aSomeString) { int index = someStrings.indexOf(aSomeString); return index; } /* Code from template attribute_GetMany */ public Integer getNumber(int index) { Integer aNumber = numbers.get(index); return aNumber; } public Integer[] getNumbers() { Integer[] newNumbers = numbers.toArray(new Integer[numbers.size()]); return newNumbers; } public int numberOfNumbers() { int number = numbers.size(); return number; } public boolean hasNumbers() { boolean has = numbers.size() > 0; return has; } public int indexOfNumber(Integer aNumber) { int index = numbers.indexOf(aNumber); return index; } /* Code from template attribute_GetMany */ public Token getObject(int index) { Token aObject = objects.get(index); return aObject; } public Token[] getObjects() { Token[] newObjects = objects.toArray(new Token[objects.size()]); return newObjects; } public int numberOfObjects() { int number = objects.size(); return number; } public boolean hasObjects() { boolean has = objects.size() > 0; return has; } public int indexOfObject(Token aObject) { int index = objects.indexOf(aObject); return index; } public void delete() {} public String toString() { return super.toString() + "["+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; /** * This is a student */ // line 4 "../ClassTemplateTest_Comment.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ import java.util.*; // line 1 "AssociationMultilineComment.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //Foo Associations private List<Bar> bars; //------------------------ // CONSTRUCTOR //------------------------ public Foo() { bars = new ArrayList<Bar>(); } //------------------------ // INTERFACE //------------------------ /* Code from template association_GetMany */ public Bar getBar(int index) { Bar aBar = bars.get(index); return aBar; } /** * I am a multiline comment above an association. */ public List<Bar> getBars() { List<Bar> newBars = Collections.unmodifiableList(bars); return newBars; } public int numberOfBars() { int number = bars.size(); return number; } public boolean hasBars() { boolean has = bars.size() > 0; return has; } public int indexOfBar(Bar aBar) { int index = bars.indexOf(aBar); return index; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfBars() { return 0; } /* Code from template association_AddManyToOne */ public Bar addBar() { return new Bar(this); } public boolean addBar(Bar aBar) { boolean wasAdded = false; if (bars.contains(aBar)) { return false; } Foo existingFoo = aBar.getFoo(); boolean isNewFoo = existingFoo != null && !this.equals(existingFoo); if (isNewFoo) { aBar.setFoo(this); } else { bars.add(aBar); } wasAdded = true; return wasAdded; } public boolean removeBar(Bar aBar) { boolean wasRemoved = false; //Unable to remove aBar, as it must always have a foo if (!this.equals(aBar.getFoo())) { bars.remove(aBar); wasRemoved = true; } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addBarAt(Bar aBar, int index) { boolean wasAdded = false; if(addBar(aBar)) { if(index < 0 ) { index = 0; } if(index > numberOfBars()) { index = numberOfBars() - 1; } bars.remove(aBar); bars.add(index, aBar); wasAdded = true; } return wasAdded; } public boolean addOrMoveBarAt(Bar aBar, int index) { boolean wasAdded = false; if(bars.contains(aBar)) { if(index < 0 ) { index = 0; } if(index > numberOfBars()) { index = numberOfBars() - 1; } bars.remove(aBar); bars.add(index, aBar); wasAdded = true; } else { wasAdded = addBarAt(aBar, index); } return wasAdded; } public void delete() { for(int i=bars.size(); i > 0; i--) { Bar aBar = bars.get(i - 1); aBar.delete(); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../ClassTemplateTest_EmptyStringAttr.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //Student Attributes private String grade; //------------------------ // CONSTRUCTOR //------------------------ public Student() { grade = ""; } //------------------------ // INTERFACE //------------------------ public boolean setGrade(String aGrade) { boolean wasSet = false; grade = aGrade; wasSet = true; return wasSet; } public String getGrade() { return grade; } public void delete() {} public String toString() { return super.toString() + "["+ "grade" + ":" + getGrade()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../ClassTemplateTest_AssociationAttributes.ump" public class Token { //------------------------ // MEMBER VARIABLES //------------------------ //Token Attributes private Position p; //------------------------ // CONSTRUCTOR //------------------------ public Token(Position aP) { p = aP; } //------------------------ // INTERFACE //------------------------ public boolean setP(Position aP) { boolean wasSet = false; p = aP; wasSet = true; return wasSet; } public Position getP() { return p; } public void delete() {} public String toString() { return super.toString() + "["+ "]" + System.getProperties().getProperty("line.separator") + " " + "p" + "=" + (getP() != null ? !getP().equals(this) ? getP().toString().replaceAll(" "," ") : "this" : "null"); } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; /** * This is a student * Multiple comments * on several lines */ // line 6 "../ClassTemplateTest_MultiComment.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "ClassTemplateTest_AbstractClass.ump" public abstract class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Foo() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ /** * I am a class comment. * * Notice how there are 4 empty lines below me. * * * * * And 2 below me. * * * These lines should come out as we see here. * Comments such as these are often used to improve readability through whitespace clarity. */ // line 15 "ClassCommentWithEmptyLines.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Foo() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "AttributeMultilineComment.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //Foo Attributes private String name; //------------------------ // CONSTRUCTOR //------------------------ public Foo(String aName) { name = aName; } //------------------------ // INTERFACE //------------------------ public boolean setName(String aName) { boolean wasSet = false; name = aName; wasSet = true; return wasSet; } /** * I am a multiline comment above an attribute. */ public String getName() { return name; } public void delete() {} public String toString() { return super.toString() + "["+ "name" + ":" + getName()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ import java.util.*; import java.lang.Thread; // line 1 "ClassTemplateTest_QueuedMethod.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //Helper Variables protected enum QueuedMethod { method1_M } QueuedMethodThread queuedMethodThread; //------------------------ // CONSTRUCTOR //------------------------ public Foo() { queuedMethodThread = new QueuedMethodThread(); } //------------------------ // INTERFACE //------------------------ public void delete() { queuedMethodThread.delete(); } public void method1 () { queuedMethodThread.putCallTo(queuedMethodThread.new QueuedMethodMessage(QueuedMethod.method1_M, null)); } // line 5 "ClassTemplateTest_QueuedMethod.ump" public void _method1(){ //implementation } private class QueuedMethodThread implements Runnable { QueuedMethodMessageQueue methodQueue; Thread methodRemoval; public QueuedMethodThread() { methodQueue = new QueuedMethodMessageQueue(); methodRemoval = new Thread(this); //start the thread for queued methods of Foo methodRemoval.start(); } protected class QueuedMethodMessage { QueuedMethod type; //QueuedMethodMessage parameters Vector<Object> param; public QueuedMethodMessage(QueuedMethod t, Vector<Object> p) { type = t; param = p; } @Override public String toString() { return type + "," + param; } } protected class QueuedMethodMessageQueue { Queue<QueuedMethodMessage> messages = new LinkedList<QueuedMethodMessage>(); public synchronized void put(QueuedMethodMessage m) { messages.add(m); notify(); } public synchronized QueuedMethodMessage getNext() { try { while (messages.isEmpty()) { wait(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); return null; } //The element to be removed QueuedMethodMessage m = messages.remove(); return (m); } } @Override public void run () { boolean status=false; while (true) { QueuedMethodMessage qmm = methodQueue.getNext(); if(qmm == null) return; switch(qmm.type) { case method1_M: _method1(); break; default: } } } public void putCallTo(QueuedMethodMessage message) { methodQueue.put(message); } public void delete() { methodRemoval.interrupt(); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "ClassTemplateTest_NoNamespace.ump" public class Token { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Token() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "MultipleAttributeComments.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //Foo Attributes private String testAttribute1; private String testAttribute2; private String testAttribute3; private String testAttribute4; //------------------------ // CONSTRUCTOR //------------------------ public Foo(String aTestAttribute1, String aTestAttribute2, String aTestAttribute3, String aTestAttribute4) { testAttribute1 = aTestAttribute1; testAttribute2 = aTestAttribute2; testAttribute3 = aTestAttribute3; testAttribute4 = aTestAttribute4; } //------------------------ // INTERFACE //------------------------ public boolean setTestAttribute1(String aTestAttribute1) { boolean wasSet = false; testAttribute1 = aTestAttribute1; wasSet = true; return wasSet; } public boolean setTestAttribute2(String aTestAttribute2) { boolean wasSet = false; testAttribute2 = aTestAttribute2; wasSet = true; return wasSet; } public boolean setTestAttribute3(String aTestAttribute3) { boolean wasSet = false; testAttribute3 = aTestAttribute3; wasSet = true; return wasSet; } public boolean setTestAttribute4(String aTestAttribute4) { boolean wasSet = false; testAttribute4 = aTestAttribute4; wasSet = true; return wasSet; } /** * Inline comment above attribute. */ public String getTestAttribute1() { return testAttribute1; } /** * Multiple inline comments * above attribute. */ public String getTestAttribute2() { return testAttribute2; } /** * Multiline comment above attribute. */ public String getTestAttribute3() { return testAttribute3; } /** * Multiple multiline comments * above attribute. */ public String getTestAttribute4() { return testAttribute4; } public void delete() {} public String toString() { return super.toString() + "["+ "testAttribute1" + ":" + getTestAttribute1()+ "," + "testAttribute2" + ":" + getTestAttribute2()+ "," + "testAttribute3" + ":" + getTestAttribute3()+ "," + "testAttribute4" + ":" + getTestAttribute4()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 8 "../ClassTemplateTest_IsA.ump" public class SubMentor extends Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public SubMentor(String aName) { super(aName); } //------------------------ // INTERFACE //------------------------ public void delete() { super.delete(); } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 13 "../ClassTemplateTest_IsA.ump" public class SubMentor2 extends Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //SubMentor2 Attributes private String subName; //------------------------ // CONSTRUCTOR //------------------------ public SubMentor2(String aName, String aSubName) { super(aName); subName = aSubName; } //------------------------ // INTERFACE //------------------------ public boolean setSubName(String aSubName) { boolean wasSet = false; subName = aSubName; wasSet = true; return wasSet; } public String getSubName() { return subName; } public void delete() { super.delete(); } public String toString() { return super.toString() + "["+ "subName" + ":" + getSubName()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; import java.util.*; // line 3 "../ClassTemplateTest_ListAttributes.ump" public class Token { //------------------------ // MEMBER VARIABLES //------------------------ //Token Attributes private List<Position> positions; //------------------------ // CONSTRUCTOR //------------------------ public Token() { positions = new ArrayList<Position>(); } //------------------------ // INTERFACE //------------------------ /* Code from template attribute_SetMany */ public boolean addPosition(Position aPosition) { boolean wasAdded = false; wasAdded = positions.add(aPosition); return wasAdded; } public boolean removePosition(Position aPosition) { boolean wasRemoved = false; wasRemoved = positions.remove(aPosition); return wasRemoved; } /* Code from template attribute_GetMany */ public Position getPosition(int index) { Position aPosition = positions.get(index); return aPosition; } public Position[] getPositions() { Position[] newPositions = positions.toArray(new Position[positions.size()]); return newPositions; } public int numberOfPositions() { int number = positions.size(); return number; } public boolean hasPositions() { boolean has = positions.size() > 0; return has; } public int indexOfPosition(Position aPosition) { int index = positions.indexOf(aPosition); return index; } public void delete() {} public String toString() { return super.toString() + "["+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "MethodCommentWithEmptyLines.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Foo() {} //------------------------ // INTERFACE //------------------------ public void delete() {} /** * I am a method comment. * * Notice how there are 4 empty lines below me. * * * * * And 2 below me. * * * These lines should come out as we see here. * Comments such as these are often used to improve readability through whitespace clarity. */ // line 19 "MethodCommentWithEmptyLines.ump" public void testMethod(){ // I am a test method. } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; // line 3 "../ClassTemplateTest_EmptyClass.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Mentor() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ import java.util.*; // line 16 "ClassTemplateTest_AbstractClassInheritance.ump" public class Teacher extends Person { //------------------------ // MEMBER VARIABLES //------------------------ //Teacher Attributes private String position; //Teacher Associations private List<Student> students; //------------------------ // CONSTRUCTOR //------------------------ public Teacher(String aName, int aAge, String aPosition) { super(aName, aAge); position = aPosition; students = new ArrayList<Student>(); } //------------------------ // INTERFACE //------------------------ public boolean setPosition(String aPosition) { boolean wasSet = false; position = aPosition; wasSet = true; return wasSet; } public String getPosition() { return position; } /* Code from template association_GetMany */ public Student getStudent(int index) { Student aStudent = students.get(index); return aStudent; } public List<Student> getStudents() { List<Student> newStudents = Collections.unmodifiableList(students); return newStudents; } public int numberOfStudents() { int number = students.size(); return number; } public boolean hasStudents() { boolean has = students.size() > 0; return has; } public int indexOfStudent(Student aStudent) { int index = students.indexOf(aStudent); return index; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfStudents() { return 0; } /* Code from template association_AddManyToOne */ public Student addStudent(String aName, int aAge, int aStudentID) { return new Student(aName, aAge, aStudentID, this); } public boolean addStudent(Student aStudent) { boolean wasAdded = false; if (students.contains(aStudent)) { return false; } Teacher existingTeacher = aStudent.getTeacher(); boolean isNewTeacher = existingTeacher != null && !this.equals(existingTeacher); if (isNewTeacher) { aStudent.setTeacher(this); } else { students.add(aStudent); } wasAdded = true; return wasAdded; } public boolean removeStudent(Student aStudent) { boolean wasRemoved = false; //Unable to remove aStudent, as it must always have a teacher if (!this.equals(aStudent.getTeacher())) { students.remove(aStudent); wasRemoved = true; } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addStudentAt(Student aStudent, int index) { boolean wasAdded = false; if(addStudent(aStudent)) { if(index < 0 ) { index = 0; } if(index > numberOfStudents()) { index = numberOfStudents() - 1; } students.remove(aStudent); students.add(index, aStudent); wasAdded = true; } return wasAdded; } public boolean addOrMoveStudentAt(Student aStudent, int index) { boolean wasAdded = false; if(students.contains(aStudent)) { if(index < 0 ) { index = 0; } if(index > numberOfStudents()) { index = numberOfStudents() - 1; } students.remove(aStudent); students.add(index, aStudent); wasAdded = true; } else { wasAdded = addStudentAt(aStudent, index); } return wasAdded; } public void delete() { for(int i=students.size(); i > 0; i--) { Student aStudent = students.get(i - 1); aStudent.delete(); } super.delete(); } public String toString() { return super.toString() + "["+ "position" + ":" + getPosition()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; /** * This is a student * Multiple comments * on several lines */ // line 6 "../ClassTemplateTest_MultiLineComment.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ import java.util.*; // line 1 "AssociationInlineComment.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //Foo Associations private List<Bar> bars; //------------------------ // CONSTRUCTOR //------------------------ public Foo() { bars = new ArrayList<Bar>(); } //------------------------ // INTERFACE //------------------------ /* Code from template association_GetMany */ public Bar getBar(int index) { Bar aBar = bars.get(index); return aBar; } /** * I am a inline comment above an association. */ public List<Bar> getBars() { List<Bar> newBars = Collections.unmodifiableList(bars); return newBars; } public int numberOfBars() { int number = bars.size(); return number; } public boolean hasBars() { boolean has = bars.size() > 0; return has; } public int indexOfBar(Bar aBar) { int index = bars.indexOf(aBar); return index; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfBars() { return 0; } /* Code from template association_AddManyToOne */ public Bar addBar() { return new Bar(this); } public boolean addBar(Bar aBar) { boolean wasAdded = false; if (bars.contains(aBar)) { return false; } Foo existingFoo = aBar.getFoo(); boolean isNewFoo = existingFoo != null && !this.equals(existingFoo); if (isNewFoo) { aBar.setFoo(this); } else { bars.add(aBar); } wasAdded = true; return wasAdded; } public boolean removeBar(Bar aBar) { boolean wasRemoved = false; //Unable to remove aBar, as it must always have a foo if (!this.equals(aBar.getFoo())) { bars.remove(aBar); wasRemoved = true; } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addBarAt(Bar aBar, int index) { boolean wasAdded = false; if(addBar(aBar)) { if(index < 0 ) { index = 0; } if(index > numberOfBars()) { index = numberOfBars() - 1; } bars.remove(aBar); bars.add(index, aBar); wasAdded = true; } return wasAdded; } public boolean addOrMoveBarAt(Bar aBar, int index) { boolean wasAdded = false; if(bars.contains(aBar)) { if(index < 0 ) { index = 0; } if(index > numberOfBars()) { index = numberOfBars() - 1; } bars.remove(aBar); bars.add(index, aBar); wasAdded = true; } else { wasAdded = addBarAt(aBar, index); } return wasAdded; } public void delete() { for(int i=bars.size(); i > 0; i--) { Bar aBar = bars.get(i - 1); aBar.delete(); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; /** * This is a student */ // line 5 "../ClassTemplateTest_GarbageComment.ump" public class Student { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Student() {} //------------------------ // INTERFACE //------------------------ public void delete() {} } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "MultipleMethodComments.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Foo() {} //------------------------ // INTERFACE //------------------------ public void delete() {} /** * Inline comment above method. */ // line 6 "MultipleMethodComments.ump" public void testMethod1(){ // I am a comment inside a method. } /** * Multiple inline comments * above method. */ // line 13 "MultipleMethodComments.ump" public void testMethod2(){ // I am a comment inside a method. } /** * Multiline comment above method. */ // line 19 "MultipleMethodComments.ump" public void testMethod3(){ // I am a comment inside a method. } /** * Multiple multiline comments * above method. */ // line 28 "MultipleMethodComments.ump" public void testMethod4(){ // I am a comment inside a method. } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ import java.util.*; // line 1 "MultipleAssociationComments.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //Foo Associations private List<Bar1> bar1s; private List<Bar2> bar2s; private List<Bar3> bar3s; private List<Bar4> bar4s; //------------------------ // CONSTRUCTOR //------------------------ public Foo() { bar1s = new ArrayList<Bar1>(); bar2s = new ArrayList<Bar2>(); bar3s = new ArrayList<Bar3>(); bar4s = new ArrayList<Bar4>(); } //------------------------ // INTERFACE //------------------------ /* Code from template association_GetMany */ public Bar1 getBar1(int index) { Bar1 aBar1 = bar1s.get(index); return aBar1; } /** * Inline comment above association. */ public List<Bar1> getBar1s() { List<Bar1> newBar1s = Collections.unmodifiableList(bar1s); return newBar1s; } public int numberOfBar1s() { int number = bar1s.size(); return number; } public boolean hasBar1s() { boolean has = bar1s.size() > 0; return has; } public int indexOfBar1(Bar1 aBar1) { int index = bar1s.indexOf(aBar1); return index; } /* Code from template association_GetMany */ public Bar2 getBar2(int index) { Bar2 aBar2 = bar2s.get(index); return aBar2; } /** * Multiple inline comments * above association. */ public List<Bar2> getBar2s() { List<Bar2> newBar2s = Collections.unmodifiableList(bar2s); return newBar2s; } public int numberOfBar2s() { int number = bar2s.size(); return number; } public boolean hasBar2s() { boolean has = bar2s.size() > 0; return has; } public int indexOfBar2(Bar2 aBar2) { int index = bar2s.indexOf(aBar2); return index; } /* Code from template association_GetMany */ public Bar3 getBar3(int index) { Bar3 aBar3 = bar3s.get(index); return aBar3; } /** * Multiline comment above association. */ public List<Bar3> getBar3s() { List<Bar3> newBar3s = Collections.unmodifiableList(bar3s); return newBar3s; } public int numberOfBar3s() { int number = bar3s.size(); return number; } public boolean hasBar3s() { boolean has = bar3s.size() > 0; return has; } public int indexOfBar3(Bar3 aBar3) { int index = bar3s.indexOf(aBar3); return index; } /* Code from template association_GetMany */ public Bar4 getBar4(int index) { Bar4 aBar4 = bar4s.get(index); return aBar4; } /** * Multiple multiline comments * above association. */ public List<Bar4> getBar4s() { List<Bar4> newBar4s = Collections.unmodifiableList(bar4s); return newBar4s; } public int numberOfBar4s() { int number = bar4s.size(); return number; } public boolean hasBar4s() { boolean has = bar4s.size() > 0; return has; } public int indexOfBar4(Bar4 aBar4) { int index = bar4s.indexOf(aBar4); return index; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfBar1s() { return 0; } /* Code from template association_AddManyToOne */ public Bar1 addBar1() { return new Bar1(this); } public boolean addBar1(Bar1 aBar1) { boolean wasAdded = false; if (bar1s.contains(aBar1)) { return false; } Foo existingFoo = aBar1.getFoo(); boolean isNewFoo = existingFoo != null && !this.equals(existingFoo); if (isNewFoo) { aBar1.setFoo(this); } else { bar1s.add(aBar1); } wasAdded = true; return wasAdded; } public boolean removeBar1(Bar1 aBar1) { boolean wasRemoved = false; //Unable to remove aBar1, as it must always have a foo if (!this.equals(aBar1.getFoo())) { bar1s.remove(aBar1); wasRemoved = true; } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addBar1At(Bar1 aBar1, int index) { boolean wasAdded = false; if(addBar1(aBar1)) { if(index < 0 ) { index = 0; } if(index > numberOfBar1s()) { index = numberOfBar1s() - 1; } bar1s.remove(aBar1); bar1s.add(index, aBar1); wasAdded = true; } return wasAdded; } public boolean addOrMoveBar1At(Bar1 aBar1, int index) { boolean wasAdded = false; if(bar1s.contains(aBar1)) { if(index < 0 ) { index = 0; } if(index > numberOfBar1s()) { index = numberOfBar1s() - 1; } bar1s.remove(aBar1); bar1s.add(index, aBar1); wasAdded = true; } else { wasAdded = addBar1At(aBar1, index); } return wasAdded; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfBar2s() { return 0; } /* Code from template association_AddManyToOne */ public Bar2 addBar2() { return new Bar2(this); } public boolean addBar2(Bar2 aBar2) { boolean wasAdded = false; if (bar2s.contains(aBar2)) { return false; } Foo existingFoo = aBar2.getFoo(); boolean isNewFoo = existingFoo != null && !this.equals(existingFoo); if (isNewFoo) { aBar2.setFoo(this); } else { bar2s.add(aBar2); } wasAdded = true; return wasAdded; } public boolean removeBar2(Bar2 aBar2) { boolean wasRemoved = false; //Unable to remove aBar2, as it must always have a foo if (!this.equals(aBar2.getFoo())) { bar2s.remove(aBar2); wasRemoved = true; } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addBar2At(Bar2 aBar2, int index) { boolean wasAdded = false; if(addBar2(aBar2)) { if(index < 0 ) { index = 0; } if(index > numberOfBar2s()) { index = numberOfBar2s() - 1; } bar2s.remove(aBar2); bar2s.add(index, aBar2); wasAdded = true; } return wasAdded; } public boolean addOrMoveBar2At(Bar2 aBar2, int index) { boolean wasAdded = false; if(bar2s.contains(aBar2)) { if(index < 0 ) { index = 0; } if(index > numberOfBar2s()) { index = numberOfBar2s() - 1; } bar2s.remove(aBar2); bar2s.add(index, aBar2); wasAdded = true; } else { wasAdded = addBar2At(aBar2, index); } return wasAdded; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfBar3s() { return 0; } /* Code from template association_AddManyToOne */ public Bar3 addBar3() { return new Bar3(this); } public boolean addBar3(Bar3 aBar3) { boolean wasAdded = false; if (bar3s.contains(aBar3)) { return false; } Foo existingFoo = aBar3.getFoo(); boolean isNewFoo = existingFoo != null && !this.equals(existingFoo); if (isNewFoo) { aBar3.setFoo(this); } else { bar3s.add(aBar3); } wasAdded = true; return wasAdded; } public boolean removeBar3(Bar3 aBar3) { boolean wasRemoved = false; //Unable to remove aBar3, as it must always have a foo if (!this.equals(aBar3.getFoo())) { bar3s.remove(aBar3); wasRemoved = true; } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addBar3At(Bar3 aBar3, int index) { boolean wasAdded = false; if(addBar3(aBar3)) { if(index < 0 ) { index = 0; } if(index > numberOfBar3s()) { index = numberOfBar3s() - 1; } bar3s.remove(aBar3); bar3s.add(index, aBar3); wasAdded = true; } return wasAdded; } public boolean addOrMoveBar3At(Bar3 aBar3, int index) { boolean wasAdded = false; if(bar3s.contains(aBar3)) { if(index < 0 ) { index = 0; } if(index > numberOfBar3s()) { index = numberOfBar3s() - 1; } bar3s.remove(aBar3); bar3s.add(index, aBar3); wasAdded = true; } else { wasAdded = addBar3At(aBar3, index); } return wasAdded; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfBar4s() { return 0; } /* Code from template association_AddManyToOne */ public Bar4 addBar4() { return new Bar4(this); } public boolean addBar4(Bar4 aBar4) { boolean wasAdded = false; if (bar4s.contains(aBar4)) { return false; } Foo existingFoo = aBar4.getFoo(); boolean isNewFoo = existingFoo != null && !this.equals(existingFoo); if (isNewFoo) { aBar4.setFoo(this); } else { bar4s.add(aBar4); } wasAdded = true; return wasAdded; } public boolean removeBar4(Bar4 aBar4) { boolean wasRemoved = false; //Unable to remove aBar4, as it must always have a foo if (!this.equals(aBar4.getFoo())) { bar4s.remove(aBar4); wasRemoved = true; } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addBar4At(Bar4 aBar4, int index) { boolean wasAdded = false; if(addBar4(aBar4)) { if(index < 0 ) { index = 0; } if(index > numberOfBar4s()) { index = numberOfBar4s() - 1; } bar4s.remove(aBar4); bar4s.add(index, aBar4); wasAdded = true; } return wasAdded; } public boolean addOrMoveBar4At(Bar4 aBar4, int index) { boolean wasAdded = false; if(bar4s.contains(aBar4)) { if(index < 0 ) { index = 0; } if(index > numberOfBar4s()) { index = numberOfBar4s() - 1; } bar4s.remove(aBar4); bar4s.add(index, aBar4); wasAdded = true; } else { wasAdded = addBar4At(aBar4, index); } return wasAdded; } public void delete() { for(int i=bar1s.size(); i > 0; i--) { Bar1 aBar1 = bar1s.get(i - 1); aBar1.delete(); } for(int i=bar2s.size(); i > 0; i--) { Bar2 aBar2 = bar2s.get(i - 1); aBar2.delete(); } for(int i=bar3s.size(); i > 0; i--) { Bar3 aBar3 = bar3s.get(i - 1); aBar3.delete(); } for(int i=bar4s.size(); i > 0; i--) { Bar4 aBar4 = bar4s.get(i - 1); aBar4.delete(); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "MethodInlineComment.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Foo() {} //------------------------ // INTERFACE //------------------------ public void delete() {} /** * I am a comment above a method. */ // line 6 "MethodInlineComment.ump" public void testMethod(){ // I am a comment inside a method. } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ import java.util.*; // line 1 "ClassTemplateTest_AbstractClassAvoidingInstantiation2.ump" public class Teacher { //------------------------ // MEMBER VARIABLES //------------------------ //Teacher Associations private List<Foo> myFooss; //------------------------ // CONSTRUCTOR //------------------------ public Teacher() { myFooss = new ArrayList<Foo>(); } //------------------------ // INTERFACE //------------------------ /* Code from template association_GetMany */ public Foo getMyFooss(int index) { Foo aMyFooss = myFooss.get(index); return aMyFooss; } public List<Foo> getMyFooss() { List<Foo> newMyFooss = Collections.unmodifiableList(myFooss); return newMyFooss; } public int numberOfMyFooss() { int number = myFooss.size(); return number; } public boolean hasMyFooss() { boolean has = myFooss.size() > 0; return has; } public int indexOfMyFooss(Foo aMyFooss) { int index = myFooss.indexOf(aMyFooss); return index; } /* Code from template association_MinimumNumberOfMethod */ public static int minimumNumberOfMyFooss() { return 0; } /* Code from template association_MaximumNumberOfMethod */ public static int maximumNumberOfMyFooss() { return 2; } /* Code from template association_AddOptionalNToOne */ public boolean addMyFooss(Foo aMyFooss) { boolean wasAdded = false; if (myFooss.contains(aMyFooss)) { return false; } if (numberOfMyFooss() >= maximumNumberOfMyFooss()) { return wasAdded; } Teacher existingTeacher = aMyFooss.getTeacher(); boolean isNewTeacher = existingTeacher != null && !this.equals(existingTeacher); if (isNewTeacher) { aMyFooss.setTeacher(this); } else { myFooss.add(aMyFooss); } wasAdded = true; return wasAdded; } public boolean removeMyFooss(Foo aMyFooss) { boolean wasRemoved = false; //Unable to remove aMyFooss, as it must always have a teacher if (!this.equals(aMyFooss.getTeacher())) { myFooss.remove(aMyFooss); wasRemoved = true; } return wasRemoved; } /* Code from template association_AddIndexControlFunctions */ public boolean addMyFoossAt(Foo aMyFooss, int index) { boolean wasAdded = false; if(addMyFooss(aMyFooss)) { if(index < 0 ) { index = 0; } if(index > numberOfMyFooss()) { index = numberOfMyFooss() - 1; } myFooss.remove(aMyFooss); myFooss.add(index, aMyFooss); wasAdded = true; } return wasAdded; } public boolean addOrMoveMyFoossAt(Foo aMyFooss, int index) { boolean wasAdded = false; if(myFooss.contains(aMyFooss)) { if(index < 0 ) { index = 0; } if(index > numberOfMyFooss()) { index = numberOfMyFooss() - 1; } myFooss.remove(aMyFooss); myFooss.add(index, aMyFooss); wasAdded = true; } else { wasAdded = addMyFoossAt(aMyFooss, index); } return wasAdded; } public void delete() { for(int i=myFooss.size(); i > 0; i--) { Foo aMyFooss = myFooss.get(i - 1); aMyFooss.delete(); } } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "MethodMultilineComment.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Foo() {} //------------------------ // INTERFACE //------------------------ public void delete() {} /** * I am a comment above a method. */ // line 8 "MethodMultilineComment.ump" public void testMethod(){ // I am a comment inside a method. } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ // line 1 "AttributeInlineComment.ump" public class Foo { //------------------------ // MEMBER VARIABLES //------------------------ //Foo Attributes private String bar; //------------------------ // CONSTRUCTOR //------------------------ public Foo(String aBar) { bar = aBar; } //------------------------ // INTERFACE //------------------------ public boolean setBar(String aBar) { boolean wasSet = false; bar = aBar; wasSet = true; return wasSet; } /** * I am a inline comment above an attribute. */ public String getBar() { return bar; } public void delete() {} public String toString() { return super.toString() + "["+ "bar" + ":" + getBar()+ "]"; } } /*PLEASE DO NOT EDIT THIS CODE*/ /*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/ package example; import java.util.Map; // line 3 "../ClassTemplateTest_Depend.ump" public class Mentor { //------------------------ // MEMBER VARIABLES //------------------------ //------------------------ // CONSTRUCTOR //------------------------ public Mentor() {} //------------------------ // INTERFACE //------------------------ public void delete() {} }