/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/30 12:30:06*/ /*This class drives: Account*/ package BankingSystem.core.tangableResources; import java.util.*; import BankingSystem.*; import BankingSystem.core.humanResources.*; import BankingSystem.core.intangableResources.*; import BankingSystem.json.*; public class Branch extends Division { //Class datatypes private String address; private String branchNumber; //Class association variables private List accounts; //Registry of our system. BankingSystemRegistry registry = BankingSystemRegistry.getInstance(); //Constructor public Branch(String aName, String aAddress, String aBranchNumber) { super(aName); address = aAddress; branchNumber = aBranchNumber; accounts = new ArrayList(); registry.add(accounts); } public boolean setAddress(String aAddress) { address = aAddress; return true; } public boolean setBranchNumber(String aBranchNumber) { branchNumber = aBranchNumber; return true; } public String getAddress() { return address; } public String getBranchNumber() { return branchNumber; } public List getAccounts() { return accounts; } public Account addAccount(int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, AccountType aAccountType, Branch aBranch) { Account newAccount; newAccount = new Account(aAccountNumber, aBalance, aCreditLimit, clients, aAccountType, this); if (!accounts.contains(newAccount)) { registry.add(newAccount); accounts.add(newAccount); } return newAccount; } public Account addAccount(Account aAccount) { if (!accounts.contains(aAccount)) accounts.add(aAccount); return aAccount; } public void delete() { //Delete all many ends first. for (Account aAccount : accounts) { aAccount.delete(); } accounts.clear(); } public void deleteAccount(Account aAccount) { if (accounts.contains(aAccount)) { accounts.remove(aAccount); //registry.removeObj(registry.getKey(aAccount)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (accounts.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)); obj.put("address", getAddress()); obj.put("branchNumber", getBranchNumber()); return obj; } }