001    package org.nakedobjects.applib;
002    
003    import org.nakedobjects.applib.annotation.Hidden;
004    
005    
006    /**
007     * Convenience super class for all domain objects that wish to interact with the container.
008     * 
009     * <p>
010     * Subclassing is NOT mandatory; the methods in this superclass can be pushed down into domain objects and
011     * another superclass used if required.
012     * 
013     * @see org.nakedobjects.applib.DomainObjectContainer
014     */
015    public abstract class AbstractDomainObject extends AbstractContainedObject {
016    
017            // {{ resolve, objectChanged
018        /**
019         * Resolve this object, populating references to other objects.
020         */
021        @Hidden
022        protected void resolve() {
023            getContainer().resolve(this);
024        }
025    
026        /**
027         * Resolve this object if the referenced object is still unknown.
028         */
029        @Hidden
030        protected void resolve(final Object referencedObject) {
031            getContainer().resolve(this, referencedObject);
032        }
033    
034        /**
035         * Notifies the container that this object has changed, so that it can be persisted.
036         */
037        @Hidden
038        protected void objectChanged() {
039            getContainer().objectChanged(this);
040        }
041            // }}
042    
043            // {{ isPersistent, makePersistent (overloads)
044        /**
045         * Whether this object is persistent.
046         * 
047         * @deprecated - instead use {@link #isPersistent(Object)}.
048         */
049        @Deprecated
050        @Hidden
051        protected boolean isPersistent() {
052            return isPersistent(this);
053        }
054    
055        /**
056         * Save this object to the persistent object store.
057         * 
058         * <p>
059         * If the object {@link #isPersistent(Object) is persistent} already, then
060         * will throw an exception.
061         * 
062         * @see #persistIfNotAlready(Object)
063         * 
064         * @deprecated - instead use {@link #persist(Object)}.
065         */
066        @Deprecated
067        @Hidden
068        protected void makePersistent() {
069            persist(this);
070        }
071    
072        /**
073         * Saves the object, but only if not already {@link #isPersistent(Object) persistent}.
074         * 
075         * @see #isPersistent(Object)
076         * @see #persist(Object)
077         * 
078         * @deprecated - instead use {@link #persistIfNotAlready(Object)}.
079         */
080        @Deprecated
081        @Hidden
082        protected void makePersistentIfNotAlready() {
083            persistIfNotAlready(this);
084        }
085    
086        /**
087         * Delete this object from the persistent object store.
088         * 
089         * @deprecated - instead use {@link #remove(Object)}.
090         */
091        @Deprecated
092        @Hidden
093        protected void disposeInstance() {
094            remove(this);
095        }
096        // }}
097        
098    }
099    
100    // Copyright (c) Naked Objects Group Ltd.