/*
 * IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
 * Template: Infrastructure9.0 [oneit.objstore.BusinessObjectTemplate.xsl]
 *   Vendor: Apache Software Foundation (Xalan XSLTC) (Version: 1.0)
 */

    
package performa.orm;

import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;

import oneit.servlets.orm.*;

// __#BUILD_NO_TABLE_NAME#: No table name == No persistence manager and scripts required.

public abstract class BaseStripePlanNPO extends NonPersistentBO
{
    // Reference instance for the object
    public static final StripePlanNPO REFERENCE_StripePlanNPO = new StripePlanNPO ();

    // Reference instance for the object
    public static final StripePlanNPO DUMMY_StripePlanNPO = new DummyStripePlanNPO ();

    // Static constants corresponding to field names
    
    public static final String FIELD_ProductID = "ProductID";
    public static final String FIELD_PlanName = "PlanName";
    public static final String FIELD_ActiveJobs = "ActiveJobs";
    public static final String MULTIPLEREFERENCE_CurrencyPlans = "CurrencyPlans";
    public static final String BACKREF_CurrencyPlans = "";

    // Static constants corresponding to searches
    

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<StripePlanNPO> HELPER_ProductID = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<StripePlanNPO> HELPER_PlanName = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<StripePlanNPO> HELPER_ActiveJobs = DefaultAttributeHelper.INSTANCE;
    

    // Private attributes corresponding to business object data
    private String _ProductID;
    private String _PlanName;
    private Integer _ActiveJobs;
    

    // Private attributes corresponding to single references
    

    // Private attributes corresponding to multiple references
    private MultipleAssociation<StripePlanNPO, CurrencyPlanNPO> _CurrencyPlans;
    

    // Map of maps of metadata
    private static final Map ATTRIBUTES_METADATA_StripePlanNPO = new LinkedHashMap ();

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_ProductID_Validators;
    private static final AttributeValidator[] FIELD_PlanName_Validators;
    private static final AttributeValidator[] FIELD_ActiveJobs_Validators;
    

    // Arrays of AttributeDecorators for each attribute
    private static final AttributeDecorator<StripePlanNPO, String>[] FIELD_ProductID_Decorators;
    private static final AttributeDecorator<StripePlanNPO, String>[] FIELD_PlanName_Decorators;
    private static final AttributeDecorator<StripePlanNPO, Integer>[] FIELD_ActiveJobs_Decorators;
    
    
    // Arrays of SingleAssocDecorators for each attribute
    
    
    // Arrays of MultiAssocDecorators for each attribute
    private static final MultiAssocDecorator<StripePlanNPO, CurrencyPlanNPO>[] MULTIPLEREFERENCE_CurrencyPlans_Decorators;
    

    // Arrays of behaviour decorators
    private static final StripePlanNPOBehaviourDecorator[] StripePlanNPO_BehaviourDecorators;
    
    static
    {
        try
        {
            
            String tmp_CurrencyPlans = CurrencyPlanNPO.BACKREF_Plan;
            
            Map  validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));

            setupAssocMetaData_CurrencyPlans();
            FIELD_ProductID_Validators = (AttributeValidator[])setupAttribMetaData_ProductID(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_PlanName_Validators = (AttributeValidator[])setupAttribMetaData_PlanName(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_ActiveJobs_Validators = (AttributeValidator[])setupAttribMetaData_ActiveJobs(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_ProductID_Decorators = (AttributeDecorator[])AttributeDecoratorUtils.getAttributeDecorators(REFERENCE_StripePlanNPO, FIELD_ProductID).toArray (new AttributeDecorator[0]);
            FIELD_PlanName_Decorators = (AttributeDecorator[])AttributeDecoratorUtils.getAttributeDecorators(REFERENCE_StripePlanNPO, FIELD_PlanName).toArray (new AttributeDecorator[0]);
            FIELD_ActiveJobs_Decorators = (AttributeDecorator[])AttributeDecoratorUtils.getAttributeDecorators(REFERENCE_StripePlanNPO, FIELD_ActiveJobs).toArray (new AttributeDecorator[0]);
            MULTIPLEREFERENCE_CurrencyPlans_Decorators = (MultiAssocDecorator[])AttributeDecoratorUtils.getMultiAssocDecorators(REFERENCE_StripePlanNPO, MULTIPLEREFERENCE_CurrencyPlans).toArray (new MultiAssocDecorator[0]);
            

            REFERENCE_StripePlanNPO.initialiseReference ();
            DUMMY_StripePlanNPO.initialiseReference ();
            StripePlanNPO_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(StripePlanNPO.class).toArray(new StripePlanNPOBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

    
    private static void setupAssocMetaData_CurrencyPlans()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "Plan");
        metaInfo.put ("name", "CurrencyPlans");
        metaInfo.put ("type", "CurrencyPlanNPO");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripePlanNPO.CurrencyPlans:", metaInfo);
        ATTRIBUTES_METADATA_StripePlanNPO.put (MULTIPLEREFERENCE_CurrencyPlans, Collections.unmodifiableMap (metaInfo));
    }
    
    
    private static List setupAttribMetaData_ProductID(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("name", "ProductID");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripePlanNPO.ProductID:", metaInfo);
        ATTRIBUTES_METADATA_StripePlanNPO.put (FIELD_ProductID, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(StripePlanNPO.class, "ProductID", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripePlanNPO.ProductID:", validators);        

        return validators;
    }
    
    private static List setupAttribMetaData_PlanName(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("name", "PlanName");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripePlanNPO.PlanName:", metaInfo);
        ATTRIBUTES_METADATA_StripePlanNPO.put (FIELD_PlanName, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(StripePlanNPO.class, "PlanName", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripePlanNPO.PlanName:", validators);        

        return validators;
    }
    
    private static List setupAttribMetaData_ActiveJobs(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("name", "ActiveJobs");
        metaInfo.put ("type", "Integer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripePlanNPO.ActiveJobs:", metaInfo);
        ATTRIBUTES_METADATA_StripePlanNPO.put (FIELD_ActiveJobs, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(StripePlanNPO.class, "ActiveJobs", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripePlanNPO.ActiveJobs:", validators);        

        return validators;
    }
    
    // END OF STATIC METADATA DEFINITION    
    
    
    
    // This constructor should not be called
    protected BaseStripePlanNPO ()
    {
    }


    protected BBCBehaviourDecorator[] getBehaviours()
    {
        return StripePlanNPO_BehaviourDecorators;
    }

    


    protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
    {
        super._initialiseNewObjAttributes (transaction);

        
        _ProductID = (String)(HELPER_ProductID.initialise (_ProductID));
        _PlanName = (String)(HELPER_PlanName.initialise (_PlanName));
        _ActiveJobs = (Integer)(HELPER_ActiveJobs.initialise (_ActiveJobs));
    }


    protected void _initialiseAssociations ()
    {
        super._initialiseAssociations ();

        _CurrencyPlans = new MultipleAssociation<StripePlanNPO, CurrencyPlanNPO> (this, MULTIPLEREFERENCE_CurrencyPlans, CurrencyPlanNPO.SINGLEREFERENCE_Plan, CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO);
    }


    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _CurrencyPlans = new MultipleAssociation<StripePlanNPO, CurrencyPlanNPO> (this, MULTIPLEREFERENCE_CurrencyPlans, CurrencyPlanNPO.SINGLEREFERENCE_Plan, CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO);
        
        return this;
    }


    /**
     * Attribute ProductID
     */
    public String getProductID ()
    {
        assertValid();
        String valToReturn = AttributeDecoratorUtils.getValue (FIELD_ProductID_Decorators, (StripePlanNPO)this, FIELD_ProductID, _ProductID);

        
        for (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
        {
            valToReturn = bhd.getProductID ((StripePlanNPO)this, valToReturn);
        }

        return valToReturn;
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preProductIDChange (String newProductID) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postProductIDChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_ProductID ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute ProductID.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setProductID (String newProductID) throws FieldException
    {
        newProductID = AttributeDecoratorUtils.setValue (FIELD_ProductID_Decorators, (StripePlanNPO)this, FIELD_ProductID, newProductID);

        boolean oldAndNewIdentical = HELPER_ProductID.compare (_ProductID, newProductID);
        
        try
        {
            for (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
            {
                newProductID = bhd.setProductID ((StripePlanNPO)this, newProductID);
                oldAndNewIdentical = HELPER_ProductID.compare (_ProductID, newProductID);
            }

            

            if (FIELD_ProductID_Validators.length > 0)
            {
                Object newProductIDObj = HELPER_ProductID.toObject (newProductID);

                if (newProductIDObj != null)
                {
                    int     loopMax = FIELD_ProductID_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_StripePlanNPO.get (FIELD_ProductID);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_ProductID_Validators[v].checkAttribute (this, FIELD_ProductID, metadata, newProductIDObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (AttributeDecoratorUtils.getWriteability (FIELD_ProductID_Decorators, (StripePlanNPO)this, FIELD_ProductID ,getWriteability_ProductID ()) != FieldWriteability.FALSE, "Field  ProductID is not writeable");
            preProductIDChange (newProductID);
            markFieldChange (FIELD_ProductID);
            _ProductID = newProductID;            
            postFieldChange (FIELD_ProductID);
            postProductIDChange ();
        }
    }

    /**
     * Attribute PlanName
     */
    public String getPlanName ()
    {
        assertValid();
        String valToReturn = AttributeDecoratorUtils.getValue (FIELD_PlanName_Decorators, (StripePlanNPO)this, FIELD_PlanName, _PlanName);

        
        for (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
        {
            valToReturn = bhd.getPlanName ((StripePlanNPO)this, valToReturn);
        }

        return valToReturn;
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void prePlanNameChange (String newPlanName) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postPlanNameChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_PlanName ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute PlanName.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setPlanName (String newPlanName) throws FieldException
    {
        newPlanName = AttributeDecoratorUtils.setValue (FIELD_PlanName_Decorators, (StripePlanNPO)this, FIELD_PlanName, newPlanName);

        boolean oldAndNewIdentical = HELPER_PlanName.compare (_PlanName, newPlanName);
        
        try
        {
            for (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
            {
                newPlanName = bhd.setPlanName ((StripePlanNPO)this, newPlanName);
                oldAndNewIdentical = HELPER_PlanName.compare (_PlanName, newPlanName);
            }

            

            if (FIELD_PlanName_Validators.length > 0)
            {
                Object newPlanNameObj = HELPER_PlanName.toObject (newPlanName);

                if (newPlanNameObj != null)
                {
                    int     loopMax = FIELD_PlanName_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_StripePlanNPO.get (FIELD_PlanName);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_PlanName_Validators[v].checkAttribute (this, FIELD_PlanName, metadata, newPlanNameObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (AttributeDecoratorUtils.getWriteability (FIELD_PlanName_Decorators, (StripePlanNPO)this, FIELD_PlanName ,getWriteability_PlanName ()) != FieldWriteability.FALSE, "Field  PlanName is not writeable");
            prePlanNameChange (newPlanName);
            markFieldChange (FIELD_PlanName);
            _PlanName = newPlanName;            
            postFieldChange (FIELD_PlanName);
            postPlanNameChange ();
        }
    }

    /**
     * Attribute ActiveJobs
     */
    public Integer getActiveJobs ()
    {
        assertValid();
        Integer valToReturn = AttributeDecoratorUtils.getValue (FIELD_ActiveJobs_Decorators, (StripePlanNPO)this, FIELD_ActiveJobs, _ActiveJobs);

        
        for (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
        {
            valToReturn = bhd.getActiveJobs ((StripePlanNPO)this, valToReturn);
        }

        return valToReturn;
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preActiveJobsChange (Integer newActiveJobs) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postActiveJobsChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_ActiveJobs ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute ActiveJobs.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setActiveJobs (Integer newActiveJobs) throws FieldException
    {
        newActiveJobs = AttributeDecoratorUtils.setValue (FIELD_ActiveJobs_Decorators, (StripePlanNPO)this, FIELD_ActiveJobs, newActiveJobs);

        boolean oldAndNewIdentical = HELPER_ActiveJobs.compare (_ActiveJobs, newActiveJobs);
        
        try
        {
            for (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
            {
                newActiveJobs = bhd.setActiveJobs ((StripePlanNPO)this, newActiveJobs);
                oldAndNewIdentical = HELPER_ActiveJobs.compare (_ActiveJobs, newActiveJobs);
            }

            

            if (FIELD_ActiveJobs_Validators.length > 0)
            {
                Object newActiveJobsObj = HELPER_ActiveJobs.toObject (newActiveJobs);

                if (newActiveJobsObj != null)
                {
                    int     loopMax = FIELD_ActiveJobs_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_StripePlanNPO.get (FIELD_ActiveJobs);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_ActiveJobs_Validators[v].checkAttribute (this, FIELD_ActiveJobs, metadata, newActiveJobsObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (AttributeDecoratorUtils.getWriteability (FIELD_ActiveJobs_Decorators, (StripePlanNPO)this, FIELD_ActiveJobs ,getWriteability_ActiveJobs ()) != FieldWriteability.FALSE, "Field  ActiveJobs is not writeable");
            preActiveJobsChange (newActiveJobs);
            markFieldChange (FIELD_ActiveJobs);
            _ActiveJobs = newActiveJobs;            
            postFieldChange (FIELD_ActiveJobs);
            postActiveJobsChange ();
        }
    }



    /**
     * A list of multi assoc names e.g. list of strings.
     */
    public List<String> getSingleAssocs()
    {
        List result = super.getSingleAssocs ();
        

        return result;
    }
    
    
    public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else
        {
            return super.getSingleAssocReferenceInstance (assocName);
        }
    }


    public String getSingleAssocBackReference(String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else
        {
            return super.getSingleAssocBackReference (assocName);
        }
    }
    
    
    public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else
        {
            return super.getSingleAssoc (assocName);
        }
    }


    public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else
        {
            return super.getSingleAssoc (assocName, getType);
        }
    }


    public Long getSingleAssocID (String assocName) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else
        {
            return super.getSingleAssocID (assocName);
        }
    }


    public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



    /**
     * A list of multi assoc names e.g. list of strings.
     */
    public List<String> getMultiAssocs()
    {
        List result = super.getMultiAssocs ();
        
        result.add("CurrencyPlans");

        return result;
    }


    /**
     * Get the reference instance for the multi assoc name.
     */
    public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
    {
        if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
        {
            return CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO ;
        }

        return super.getMultiAssocReferenceInstance(attribName);
    }


    public String getMultiAssocBackReference(String attribName)
    {
        if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
        {
            return CurrencyPlanNPO.SINGLEREFERENCE_Plan ;
        }

        return super.getMultiAssocBackReference(attribName);
    }


    /**
     * Get the assoc count for the multi assoc name.
     */
    public int getMultiAssocCount(String attribName) throws StorageException
    {
        if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
        {
            return this.getCurrencyPlansCount();
        }

        return super.getMultiAssocCount(attribName);
    }


    /**
     * Get the assoc at a particular index
     */
    public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
    {
        if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
        {
            return this.getCurrencyPlansAt(index);
        }

        return super.getMultiAssocAt(attribName, index);
    }


    /**
     * Add to a multi assoc by attribute name
     */
    public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
    {
        if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
        {
            addToCurrencyPlans((CurrencyPlanNPO)newElement);
            return;
        }

        super.addToMultiAssoc(attribName, newElement);
    }

    /**
     * Remove from a multi assoc by attribute name
     */
    public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
    {
        if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
        {
            removeFromCurrencyPlans((CurrencyPlanNPO)oldElement);
            return;
        }

        super.removeFromMultiAssoc(attribName, oldElement);
    }


    protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
    {
        if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
        {
            _CurrencyPlans.__loadAssociation (elements);
            return;
        }

        super.__loadMultiAssoc(attribName, elements);
    }


    protected boolean __isMultiAssocLoaded (String attribName)
    {
        if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
        {
            return _CurrencyPlans.isLoaded ();
        }

        return super.__isMultiAssocLoaded(attribName);
    }


    public FieldWriteability getWriteability_CurrencyPlans ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getCurrencyPlansCount () throws StorageException
    {
        assertValid();
        return _CurrencyPlans.getReferencedObjectsCount ();
    }


    public void addToCurrencyPlans (CurrencyPlanNPO newElement) throws StorageException
    {
        if (_CurrencyPlans.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (AttributeDecoratorUtils.getWriteability (MULTIPLEREFERENCE_CurrencyPlans_Decorators, (StripePlanNPO)this, MULTIPLEREFERENCE_CurrencyPlans ,getWriteability_CurrencyPlans ()) != FieldWriteability.FALSE, "MultiAssoc CurrencyPlans is not writeable (add)");
            _CurrencyPlans.appendElement (newElement);

            try
            {
                if (newElement.getPlan () != this)
                {
                    newElement.setPlan ((StripePlanNPO)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromCurrencyPlans (CurrencyPlanNPO elementToRemove) throws StorageException
    {
        if (_CurrencyPlans.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (AttributeDecoratorUtils.getWriteability (MULTIPLEREFERENCE_CurrencyPlans_Decorators, (StripePlanNPO)this, MULTIPLEREFERENCE_CurrencyPlans ,getWriteability_CurrencyPlans ()) != FieldWriteability.FALSE, "MultiAssoc CurrencyPlans is not writeable (remove)");
            _CurrencyPlans.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getPlan () != null)
                {
                    elementToRemove.setPlan (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public CurrencyPlanNPO getCurrencyPlansAt (int index) throws StorageException
    {
        return (CurrencyPlanNPO)(_CurrencyPlans.getElementAt (index));
    }


    public SortedSet<CurrencyPlanNPO> getCurrencyPlansSet () throws StorageException
    {
        return _CurrencyPlans.getSet ();
    }



    public void onDelete ()
    {
        try 
        {
            for(CurrencyPlanNPO referenced : CollectionUtils.reverse(getCurrencyPlansSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Plan from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setPlan(null);
            }

        }
        catch (Exception e)
        {
            throw NestedException.wrap(e);
        }

        super.onDelete ();
    }


    public StripePlanNPO newInstance ()
    {
        return new StripePlanNPO ();
    }


    public StripePlanNPO referenceInstance ()
    {
        return REFERENCE_StripePlanNPO;
    }


    public StripePlanNPO getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getStripePlanNPOByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_StripePlanNPO;
    }


    public String getBaseSetName ()
    {
        return "";
    }



    /**
     * This is where an object returns the Persistent sets that will
     * store it into the database.
     * The should be entered into allSets
     */
    public void getPersistentSets (PersistentSetCollection allSets)
    {
        ObjectStatus        myStatus = getStatus ();
        PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
        ObjectID            myID = getID();

        super.getPersistentSets (allSets);
        
        PersistentSet   PSet = allSets.getPersistentSet (myID, "", myPSetStatus);

        PSet.setAttrib (FIELD_ObjectID, myID);
        PSet.setAttrib (FIELD_ProductID, HELPER_ProductID.toObject (_ProductID)); //
        PSet.setAttrib (FIELD_PlanName, HELPER_PlanName.toObject (_PlanName)); //
        PSet.setAttrib (FIELD_ActiveJobs, HELPER_ActiveJobs.toObject (_ActiveJobs)); //
        
    }


    /**
     * Sets the objects state based on Persistent sets.
     */
    public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
    {
        super.setFromPersistentSets (objectID, allSets);
        
        PersistentSet   PSet = allSets.getPersistentSet (objectID, "");

        _ProductID = (String)(HELPER_ProductID.fromObject (_ProductID, PSet.getAttrib (FIELD_ProductID))); //
        _PlanName = (String)(HELPER_PlanName.fromObject (_PlanName, PSet.getAttrib (FIELD_PlanName))); //
        _ActiveJobs = (Integer)(HELPER_ActiveJobs.fromObject (_ActiveJobs, PSet.getAttrib (FIELD_ActiveJobs))); //
        
    }


    public void setAttributesFrom (BaseBusinessClass other, MultiException e)
    {
        super.setAttributesFrom (other, e);

        if (other instanceof StripePlanNPO)
        {
            StripePlanNPO otherStripePlanNPO = (StripePlanNPO)other;
            

            try
            {
                setProductID (otherStripePlanNPO.getProductID ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }

            try
            {
                setPlanName (otherStripePlanNPO.getPlanName ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }

            try
            {
                setActiveJobs (otherStripePlanNPO.getActiveJobs ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
        }
    }


    /**
     * Set the attributes in this to copies of the attributes in source.
     */
    public void copyAttributesFrom (BaseBusinessClass source)
    {
        super.copyAttributesFrom (source);

        if (source instanceof BaseStripePlanNPO)
        {
            BaseStripePlanNPO sourceStripePlanNPO = (BaseStripePlanNPO)(source);

            _ProductID = sourceStripePlanNPO._ProductID;
            _PlanName = sourceStripePlanNPO._PlanName;
            _ActiveJobs = sourceStripePlanNPO._ActiveJobs;
            
        }
    }


    /**
     * Set the associations in this to copies of the attributes in source.
     */
    public void copySingleAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
    {
        super.copySingleAssociationsFrom (source, linkToGhosts);

        if (source instanceof BaseStripePlanNPO)
        {
            BaseStripePlanNPO sourceStripePlanNPO = (BaseStripePlanNPO)(source);

            
        }
    }


    /**
     * Set the associations in this to copies of the attributes in source.
     */
    public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
    {
        super.copyAssociationsFrom (source, linkToGhosts);

        if (source instanceof BaseStripePlanNPO)
        {
            BaseStripePlanNPO sourceStripePlanNPO = (BaseStripePlanNPO)(source);

            _CurrencyPlans.copyFrom (sourceStripePlanNPO._CurrencyPlans, linkToGhosts);
            
        }
    }


    public void validate (ValidationContext context)
    {
        super.validate (context);

        
    }


    /**
     * Subclasses must override this to read in their attributes
     */
    protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
    {
        super.readExternalData(vals);

        _ProductID = (String)(HELPER_ProductID.readExternal (_ProductID, vals.get(FIELD_ProductID))); //
        _PlanName = (String)(HELPER_PlanName.readExternal (_PlanName, vals.get(FIELD_PlanName))); //
        _ActiveJobs = (Integer)(HELPER_ActiveJobs.readExternal (_ActiveJobs, vals.get(FIELD_ActiveJobs))); //
        _CurrencyPlans.readExternalData(vals.get(MULTIPLEREFERENCE_CurrencyPlans));
        
    }


    /**
     * Subclasses must override this to write out their attributes
     */
    protected void writeExternalData(Map<String, Object> vals) throws IOException
    {
        super.writeExternalData(vals);

        vals.put (FIELD_ProductID, HELPER_ProductID.writeExternal (_ProductID));
        vals.put (FIELD_PlanName, HELPER_PlanName.writeExternal (_PlanName));
        vals.put (FIELD_ActiveJobs, HELPER_ActiveJobs.writeExternal (_ActiveJobs));
        vals.put (MULTIPLEREFERENCE_CurrencyPlans, _CurrencyPlans.writeExternalData());
        
    }


    public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
    {
        super.compare (other, listener);

        if (other instanceof BaseStripePlanNPO)
        {
            BaseStripePlanNPO otherStripePlanNPO = (BaseStripePlanNPO)(other);

            
            if (!HELPER_ProductID.compare(this._ProductID, otherStripePlanNPO._ProductID))
            {
                listener.notifyFieldChange(this, other, FIELD_ProductID, HELPER_ProductID.toObject(this._ProductID), HELPER_ProductID.toObject(otherStripePlanNPO._ProductID));
            }
            if (!HELPER_PlanName.compare(this._PlanName, otherStripePlanNPO._PlanName))
            {
                listener.notifyFieldChange(this, other, FIELD_PlanName, HELPER_PlanName.toObject(this._PlanName), HELPER_PlanName.toObject(otherStripePlanNPO._PlanName));
            }
            if (!HELPER_ActiveJobs.compare(this._ActiveJobs, otherStripePlanNPO._ActiveJobs))
            {
                listener.notifyFieldChange(this, other, FIELD_ActiveJobs, HELPER_ActiveJobs.toObject(this._ActiveJobs), HELPER_ActiveJobs.toObject(otherStripePlanNPO._ActiveJobs));
            }

            // Compare single assocs
            

            // Compare multiple assocs
            _CurrencyPlans.compare (otherStripePlanNPO._CurrencyPlans, listener);
            
        }
    }


    public void visitTransients (AttributeVisitor visitor) throws StorageException
    {
        super.visitAttributes (visitor);

        
    }


    public void visitAttributes (AttributeVisitor visitor) throws StorageException
    {
        super.visitAttributes (visitor);

        visitor.visitField(this, FIELD_ProductID, HELPER_ProductID.toObject(getProductID()));
        visitor.visitField(this, FIELD_PlanName, HELPER_PlanName.toObject(getPlanName()));
        visitor.visitField(this, FIELD_ActiveJobs, HELPER_ActiveJobs.toObject(getActiveJobs()));
        visitor.visitAssociation (_CurrencyPlans);
        
    }


    public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
    {
        super.visitAssociations (visitor, scope);

        if (scope.includes (_CurrencyPlans))
        {
            visitor.visit (_CurrencyPlans);
        }
        
    }


    public static StripePlanNPO createStripePlanNPO (ObjectTransaction transaction) throws StorageException
    {
        StripePlanNPO     result = new StripePlanNPO ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static StripePlanNPO getStripePlanNPOByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (StripePlanNPO)(transaction.getObjectByID (REFERENCE_StripePlanNPO, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_ProductID))
        {
            return filter.matches (getProductID ());
        }
        else if (attribName.equals (FIELD_PlanName))
        {
            return filter.matches (getPlanName ());
        }
        else if (attribName.equals (FIELD_ActiveJobs))
        {
            return filter.matches (getActiveJobs ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }




    public Object getAttribute (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_ProductID))
        {
            return HELPER_ProductID.toObject (getProductID ());
        }
        else if (attribName.equals (FIELD_PlanName))
        {
            return HELPER_PlanName.toObject (getPlanName ());
        }
        else if (attribName.equals (FIELD_ActiveJobs))
        {
            return HELPER_ActiveJobs.toObject (getActiveJobs ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_ProductID))
        {
            return HELPER_ProductID;
        }
        else if (attribName.equals (FIELD_PlanName))
        {
            return HELPER_PlanName;
        }
        else if (attribName.equals (FIELD_ActiveJobs))
        {
            return HELPER_ActiveJobs;
        }
        else
        {
            return super.getAttributeHelper (attribName);
        }
    }


    public void setAttribute (String attribName, Object attribValue) throws FieldException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_ProductID))
        {
            setProductID ((String)(HELPER_ProductID.fromObject (_ProductID, attribValue)));            
        }
        else if (attribName.equals (FIELD_PlanName))
        {
            setPlanName ((String)(HELPER_PlanName.fromObject (_PlanName, attribValue)));            
        }
        else if (attribName.equals (FIELD_ActiveJobs))
        {
            setActiveJobs ((Integer)(HELPER_ActiveJobs.fromObject (_ActiveJobs, attribValue)));            
        }
        else
        {
            super.setAttribute (attribName, attribValue);
        }
    }

    

    public boolean isWriteable (String fieldName)
    {        
        return getWriteable (fieldName) == FieldWriteability.TRUE;
    }

    public boolean isReadable ()
    {
        return super.isReadable();
    }

    public boolean isReadable (String fieldName)
    {
        return super.isReadable(fieldName);
    }


    public FieldWriteability getWriteable (String fieldName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (fieldName.equals (FIELD_ProductID))
        {
            return getWriteability_ProductID ();
        }
        else if (fieldName.equals (FIELD_PlanName))
        {
            return getWriteability_PlanName ();
        }
        else if (fieldName.equals (FIELD_ActiveJobs))
        {
            return getWriteability_ActiveJobs ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_CurrencyPlans))
        {
            return getWriteability_CurrencyPlans ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        if (getWriteability_ProductID () != FieldWriteability.TRUE)
        {
            fields.add (FIELD_ProductID);
        }
        
        if (getWriteability_PlanName () != FieldWriteability.TRUE)
        {
            fields.add (FIELD_PlanName);
        }
        
        if (getWriteability_ActiveJobs () != FieldWriteability.TRUE)
        {
            fields.add (FIELD_ActiveJobs);
        }
        

        super.putUnwriteable (fields);
    }

    // This generally means there's no specific persistence manager and we don't read or write from a table
    public boolean hasNoTable()
    {
        return true;
    }


    public List<AbstractAttribute> getAttributes ()
    {
        List result = super.getAttributes ();

        
        result.add(HELPER_ProductID.getAttribObject (getClass (), _ProductID, false, FIELD_ProductID));
        result.add(HELPER_PlanName.getAttribObject (getClass (), _PlanName, false, FIELD_PlanName));
        result.add(HELPER_ActiveJobs.getAttribObject (getClass (), _ActiveJobs, false, FIELD_ActiveJobs));

        return result;
    }


    public Map getAttributeMetadata (String attribute)
    {
        if (ATTRIBUTES_METADATA_StripePlanNPO.containsKey (attribute))
        {
            return (Map)ATTRIBUTES_METADATA_StripePlanNPO.get (attribute);
        }
        else
        {
            return super.getAttributeMetadata (attribute);
        }
    }


    public Object getAttributeMetadata (String attribute, String metadata)
    {
        if (ATTRIBUTES_METADATA_StripePlanNPO.containsKey (attribute))
        {
            return ((Map)ATTRIBUTES_METADATA_StripePlanNPO.get (attribute)).get(metadata);
        }
        else
        {
            return super.getAttributeMetadata (attribute, metadata);
        }
    }

    public void copyAllAttributeMetadata (Map copyInto)
    {
        super.copyAllAttributeMetadata(copyInto);

        copyInto.putAll(ATTRIBUTES_METADATA_StripePlanNPO);
    }
            

    public void preCommit (boolean willBeStored) throws Exception
    {
        super.preCommit(willBeStored);
        
        if(willBeStored)
        {
        
        }
    }

    public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
    {
        
        return super.getBinaryContentHandler(attribName);
    }

    public static class StripePlanNPOBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<StripePlanNPO>
    {

    /**
     * Get the attribute ProductID
     */
    public String getProductID (StripePlanNPO obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute ProductID.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setProductID (StripePlanNPO obj, String newProductID) throws FieldException
    {
        return newProductID;
    }

    /**
     * Get the attribute PlanName
     */
    public String getPlanName (StripePlanNPO obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute PlanName.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setPlanName (StripePlanNPO obj, String newPlanName) throws FieldException
    {
        return newPlanName;
    }

    /**
     * Get the attribute ActiveJobs
     */
    public Integer getActiveJobs (StripePlanNPO obj, Integer original)
    {
        return original;
    }

    /**
     * Change the value set for attribute ActiveJobs.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Integer setActiveJobs (StripePlanNPO obj, Integer newActiveJobs) throws FieldException
    {
        return newActiveJobs;
    }

    }

    @Override
    public ORMPipeLine pipes()
    {
        return new StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> ((StripePlanNPO)this);
    }

    @Override
    public ORMPipeLine pipes(Collection _items)
    {
        return pipesStripePlanNPO(_items);
    }
      
    /**
     * Use this instead of pipes() to get rid of type casting.
     */  
    public StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> pipelineStripePlanNPO()
    {
        return (StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO>) pipes();
    }
    
    public static StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> pipesStripePlanNPO(Collection<StripePlanNPO> items)
    {
        return REFERENCE_StripePlanNPO.new StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> (items);
    }
    
    public static StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> pipesStripePlanNPO(StripePlanNPO[] _items)
    {
        return pipesStripePlanNPO(Arrays.asList (_items));
    }
    
    public static StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> pipesStripePlanNPO()
    {
        return pipesStripePlanNPO((Collection)null);
    }
    
    
    public class StripePlanNPOPipeLineFactory<From extends BaseBusinessClass, Me extends StripePlanNPO> extends NonPersistentBOPipeLineFactory<From, Me>    
    {
        public <Prev> StripePlanNPOPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
        {
            super (pipeLine, nextPipe);
        }
        
        public StripePlanNPOPipeLineFactory (From seed)
        {
            super(seed);
        }

        public StripePlanNPOPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("CurrencyPlans"))
            {
                return toCurrencyPlans ();
            }                
            if (name.equals ("ProductID"))
            {
                return toProductID ();
            }                
            if (name.equals ("PlanName"))
            {
                return toPlanName ();
            }                
            if (name.equals ("ActiveJobs"))
            {
                return toActiveJobs ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, String> toProductID () { return pipe(new ORMAttributePipe<Me, String>(FIELD_ProductID));  }
        
        public PipeLine<From, String> toPlanName () { return pipe(new ORMAttributePipe<Me, String>(FIELD_PlanName));  }
        
        public PipeLine<From, Integer> toActiveJobs () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_ActiveJobs));  }

        public CurrencyPlanNPO.CurrencyPlanNPOPipeLineFactory<From, CurrencyPlanNPO> toCurrencyPlans () { return toCurrencyPlans(Filter.ALL); }        

        public CurrencyPlanNPO.CurrencyPlanNPOPipeLineFactory<From, CurrencyPlanNPO> toCurrencyPlans (Filter<CurrencyPlanNPO> filter)
        {
            return CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO.new CurrencyPlanNPOPipeLineFactory<From, CurrencyPlanNPO> (this, new ORMMultiAssocPipe<Me, CurrencyPlanNPO>(MULTIPLEREFERENCE_CurrencyPlans, filter)); 
        }
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

class DummyStripePlanNPO extends StripePlanNPO
{
    // Default constructor primarily to support Externalisable
    public DummyStripePlanNPO()
    {
        super();
    }

    public void assertValid ()
    {
    }


    public int getCurrencyPlansCount () throws StorageException
    {
        return 0;
    }


    public CurrencyPlanNPO getCurrencyPlansAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association CurrencyPlans");
    }


    public SortedSet getCurrencyPlansSet () throws StorageException
    {
        return new TreeSet();
    }

}

    
