package devguide.advanced.inheritance;

import oracle.jbo.Key;
import oracle.jbo.domain.Date;
import oracle.jbo.domain.Number;
import oracle.jbo.server.AttributeDefImpl;
import oracle.jbo.server.EntityDefImpl;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class SupplierImpl extends PersonsImpl {
    public static final int MAXATTRCONST = EntityDefImpl.getMaxAttrConst("devguide.advanced.inheritance.Persons");
    public static final int CONTRACTEXPIRES = MAXATTRCONST;
    private static EntityDefImpl mDefinitionObject;

    /**This is the default constructor (do not remove).
     */
    public SupplierImpl() {
    }

    /**@return the definition object for this instance class.
     */
    public static synchronized EntityDefImpl getDefinitionObject() {
        if (mDefinitionObject == null) {
            mDefinitionObject = EntityDefImpl.findDefObject("devguide.advanced.inheritance.Supplier");
        }
        return mDefinitionObject;
    }

    /**Gets the attribute value for PersonTypeCode, using the alias name PersonTypeCode.
     */
    public String getPersonTypeCode() {
        return super.getPersonTypeCode();
    }

    /**Sets <code>value</code> as the attribute value for PersonTypeCode.
     */
    public void setPersonTypeCode(String value) {
        super.setPersonTypeCode(value);
    }

    /**Gets the attribute value for ContractExpires, using the alias name ContractExpires.
     */
    public Date getContractExpires() {
        return (Date)getAttributeInternal(CONTRACTEXPIRES);
    }

    /**Sets <code>value</code> as the attribute value for ContractExpires.
     */
    public void setContractExpires(Date value) {
        setAttributeInternal(CONTRACTEXPIRES, value);
    }

    /**getAttrInvokeAccessor: generated method. Do not modify.
     */
    protected Object getAttrInvokeAccessor(int index, 
                                           AttributeDefImpl attrDef) throws Exception {
        if (index == CONTRACTEXPIRES) {
            return getContractExpires();
        }
        if (index == PERSONTYPECODE) {
            return getPersonTypeCode();
        }
        return super.getAttrInvokeAccessor(index, attrDef);
    }

    /**setAttrInvokeAccessor: generated method. Do not modify.
     */
    protected void setAttrInvokeAccessor(int index, Object value, 
                                         AttributeDefImpl attrDef) throws Exception {
        if (index == CONTRACTEXPIRES) {
            setContractExpires((Date)value);
            return;
        }
        if (index == PERSONTYPECODE) {
            setPersonTypeCode((String)value);
            return;
        }
        super.setAttrInvokeAccessor(index, value, attrDef);
        return;
    }

    /**Creates a Key object based on given key constituents.
     */
    public static Key createPrimaryKey(Number personId) {
        return new Key(new Object[]{personId});
    }

    @Override
    public void performPersonFunction() {
        System.out.println("## performPersonFunction as Supplier");
    }
    
    public void performSupplierFunction() {
    System.out.println("## performSupplierFunction called");
    }
}
