package api.unicore.component;
 
import static api.util.ComponentConstants.DATE_NULL;
import static api.util.ComponentConstants.DATE_NULL_CODE;
import static api.util.ComponentConstants.INTEGER_NULL;
import static api.util.ComponentConstants.INTEGER_NULL_CODE;
import static api.util.ComponentConstants.STRING_NULL;
import static api.util.ComponentConstants.STRING_NULL_CODE;
import static org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion.NON_NULL;
 
import api.UnoComponent;
import api.unicore.component_manual.Bankruptcy;
import api.util.DateFormat;
import api.util.IntegerFormat;
import api.util.StringFormat;
import iapp.services.ServerObject;
import iapp.util.audit.AuditHelper;
import java.util.Date;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.FormParam;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.codehaus.jackson.annotate.JsonPropertyOrder;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
 
/**
 * @author CodeGen
 * @company UnitedThinkers
 * @since 2013/05/07
 */
 
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"type", "count", "companyName", "street1", "street2", "city", "state", "zipCode", "filingDate"})
@JsonPropertyOrder({"type", "count", "companyName", "street1", "street2", "city", "state", "zipCode", "filingDate"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(Bankruptcy.class)
public abstract class AbstractBankruptcy extends UnoComponent<unicore.model.BackgroundVerificationResult> {
 
    @FormParam("type")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String type;
 
    @FormParam("count")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer count;
 
    @FormParam("companyName")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String companyName;
 
    @FormParam("street1")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String street1;
 
    @FormParam("street2")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String street2;
 
    @FormParam("city")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String city;
 
    @FormParam("state")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String state;
 
    @FormParam("zipCode")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String zipCode;
 
    @FormParam("filingDate")
    @DateFormat
    @DefaultValue(DATE_NULL_CODE)
    protected Date filingDate;
 
 
    public AbstractBankruptcy(){
        super();
        applyDefaults();
    }
 
    public AbstractBankruptcy(unicore.model.BackgroundVerificationResult object){
        super(object);
    }
 
 
    private void applyDefaults() {
        if (!isProxyObject()) {
            type = STRING_NULL;
            count = INTEGER_NULL;
            companyName = STRING_NULL;
            street1 = STRING_NULL;
            street2 = STRING_NULL;
            city = STRING_NULL;
            state = STRING_NULL;
            zipCode = STRING_NULL;
            filingDate = DATE_NULL;
        }
    }
 
    @Override
    public void from() {
        fromInternal();
        super.from();
    }
 
    protected abstract void fromInternal();
    @Override
    public abstract void to();
    @Override
    public abstract void initializeNew();
 
    @Override
    public String toString(){
        StringBuilder sb = new StringBuilder();
        sb.append("bankruptcy: {");
        sb.append("type: ");
        sb.append(type);
        sb.append(',').append(' ');
        sb.append("count: ");
        sb.append(count);
        sb.append(',').append(' ');
        sb.append("companyName: ");
        sb.append(companyName);
        sb.append(',').append(' ');
        sb.append("street1: ");
        sb.append(street1);
        sb.append(',').append(' ');
        sb.append("street2: ");
        sb.append(street2);
        sb.append(',').append(' ');
        sb.append("city: ");
        sb.append(city);
        sb.append(',').append(' ');
        sb.append("state: ");
        sb.append(state);
        sb.append(',').append(' ');
        sb.append("zipCode: ");
        sb.append(zipCode);
        sb.append(',').append(' ');
        sb.append("filingDate: ");
        sb.append(filingDate);
        sb.append('}');
        return sb.toString();
    }
 
 
    @XmlAttribute(name="type")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("type")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getType(){
        return type;
    }
 
    public void setType(String value){
        this.type = value;
    }
 
    @XmlAttribute(name="count")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("count")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Integer getCount(){
        return count;
    }
 
    public void setCount(Integer value){
        this.count = value;
    }
 
    @XmlAttribute(name="companyName")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("companyName")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getCompanyName(){
        return companyName;
    }
 
    public void setCompanyName(String value){
        this.companyName = value;
    }
 
    @XmlAttribute(name="street1")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("street1")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getStreet1(){
        return street1;
    }
 
    public void setStreet1(String value){
        this.street1 = value;
    }
 
    @XmlAttribute(name="street2")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("street2")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getStreet2(){
        return street2;
    }
 
    public void setStreet2(String value){
        this.street2 = value;
    }
 
    @XmlAttribute(name="city")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("city")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getCity(){
        return city;
    }
 
    public void setCity(String value){
        this.city = value;
    }
 
    @XmlAttribute(name="state")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("state")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getState(){
        return state;
    }
 
    public void setState(String value){
        this.state = value;
    }
 
    @XmlAttribute(name="zipCode")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("zipCode")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getZipCode(){
        return zipCode;
    }
 
    public void setZipCode(String value){
        this.zipCode = value;
    }
 
    @XmlAttribute(name="filingDate")
    @FormParam("filingDate")
    @DateFormat
    @JsonDeserialize(using=api.util.DateDeserializer.class)
    public Date getFilingDate(){
        return filingDate;
    }
 
    public void setFilingDate(Date value){
        this.filingDate = value;
    }
 
 
    public void audit(AuditHelper helper, ServerObject object) {
        unicore.model.BackgroundVerificationResult s_object = (unicore.model.BackgroundVerificationResult) object;
        helper.audit("type", type, s_object.getBankruptcyType());
        helper.audit("count", count, s_object.getBankruptcyCount());
        helper.audit("companyName", companyName, s_object.getBankruptcyCompanyName());
        helper.audit("street1", street1, s_object.getBankruptcyStreet1());
        helper.audit("street2", street2, s_object.getBankruptcyStreet2());
        helper.audit("city", city, s_object.getBankruptcyCity());
        helper.audit("state", state, s_object.getBankruptcyState());
        helper.audit("zipCode", zipCode, s_object.getBankruptcyZipCode());
        helper.audit("filingDate", filingDate, s_object.getBankruptcyFilingDate());
 
    }
 
 
}