/*This code was generated using the UMPLE modeling language!
 Date of generation: 2008/07/30 11:46:04*/
/*This class drives: */

package telesystem.core;

import telesystem.*;
import telesystem.json.*;

public class Telephone {
  //Class datatypes
  private String model;

  //Class association variables
  private PhoneLine phoneLine;

  //Registry of our system.
  TelesystemRegistry registry = TelesystemRegistry.getInstance();

  //Constructor
  public Telephone(String aModel, PhoneLine aPhoneLine) {
    model = aModel;
    phoneLine = aPhoneLine;

  }

  public boolean setModel(String aModel) {
    model = aModel;
    return true;
  }

  public String getModel() {
    return model;
  }

  public PhoneLine getPhoneLine() {
    return phoneLine;
  }

  /* This class does not drive PhoneLine and therefore sets the association unidirectionally.*/
  public void setPhoneLine(PhoneLine aPhoneLine) {
    phoneLine = aPhoneLine;
  }

  public void delete() {
    //Delete all 1 ends.
    phoneLine.deleteTelephone(this);
  }

  public boolean areManyEndsNull() {
    return true;
  }

  /***********************************
   * 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("model", getModel());
    return obj;
  }

}