/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/30 12:41:46*/ /*This class drives: Branch*/ package BankingSystem.core; import java.util.*; import BankingSystem.*; import BankingSystem.json.*; public class Bank extends FinancialInstitution { //Class datatypes //Class association variables private List branchs; //Registry of our system. BankingSystemRegistry registry = BankingSystemRegistry.getInstance(); //Constructor public Bank(String aName) { super(aName); branchs = new ArrayList(); registry.add(branchs); } public List getBranchs() { return branchs; } public Branch addBranch(String aName, String aAddress, Bank aBank) { Branch newBranch; newBranch = new Branch(aName, aAddress, this); if (!branchs.contains(newBranch)) { registry.add(newBranch); branchs.add(newBranch); } return newBranch; } public Branch addBranch(Branch aBranch) { if (!branchs.contains(aBranch)) branchs.add(aBranch); return aBranch; } public void delete() { //Delete all many ends first. for (Branch aBranch : branchs) { aBranch.delete(); } branchs.clear(); } public void deleteBranch(Branch aBranch) { if (branchs.contains(aBranch)) { branchs.remove(aBranch); //registry.removeObj(registry.getKey(aBranch)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (branchs.size() == 0) { return true; } else return false; } /*********************************** * Returns the attribute list along with the * class ID in JSON format. ***********************************/ public JSONObject getAttributes() throws JSONException { JSONObject obj = new JSONObject(); obj.put("CLASS_ID", registry.getKey(this)); return obj; } }