/*This code was generated using the UMPLE modeling language!
 Date of generation: 2008/07/30 11:21:38*/
/*This class drives: PropertyInsurancePolicy*/

package insurance.core;

import java.sql.Date;
import insurance.*;
import insurance.json.*;

public class InsuredProperty {
  //Class datatypes
  private String yearBuilt;

  //Class association variables
  private PropertyInsurancePolicy propertyInsurancePolicy;

  //Registry of our system.
  InsuranceRegistry registry = InsuranceRegistry.getInstance();

  //Constructor
  public InsuredProperty(String aYearBuilt,
    PropertyInsurancePolicy aPropertyInsurancePolicy) {
    yearBuilt = aYearBuilt;
    propertyInsurancePolicy = aPropertyInsurancePolicy;

  }

  public boolean setYearBuilt(String aYearBuilt) {
    yearBuilt = aYearBuilt;
    return true;
  }

  public String getYearBuilt() {
    return yearBuilt;
  }

  public PropertyInsurancePolicy getPropertyInsurancePolicy() {
    return propertyInsurancePolicy;
  }

  /* This class does not drive PropertyInsurancePolicy and therefore sets the association unidirectionally.*/
  public void setPropertyInsurancePolicy(
    PropertyInsurancePolicy aPropertyInsurancePolicy) {
    propertyInsurancePolicy = aPropertyInsurancePolicy;
  }

  public void delete() {
    //Delete all 1 ends.
    propertyInsurancePolicy.delete();
  }

  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("yearBuilt", getYearBuilt());
    return obj;
  }

}