Subversion Repositories SmartDukaan

Rev

Rev 1165 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * 
 */
package in.shop2020.metamodel.core;


import in.shop2020.metamodel.util.MetaModelComponent;

import java.util.ArrayList;
import java.util.List;

/**
 * Slide is the top level container class for Product features. Name comes 
 * from slide-show metaphor used for designing content-meta model. Slide can 
 * have multiple children slides, features and free-form content of its own.
 * 
 * @author naveen
 *
 */
public class Slide extends MetaModelComponent {
        
        
        Slide() {
        }

        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        
        /**
         * Reference to definition object
         */
        private long slideDefinitionID;
        
        /**
         * List of children slides
         */
        private List<Slide> childrenSlides;
        
        /**
         * List of features grouped under the slide
         */
        private List<Feature> features;
        
        /**
         * Un-structured data
         */
        private FreeformContent freeformContent;
                
        /**
         * Reference to source category
         */
        //private long borrowedCategoryID;

        /**
         * 
         * @param slideDefinitionID Slide Definition ID
         */ 
    public Slide(long slideDefinitionID) {
        this.slideDefinitionID = slideDefinitionID;
    }

    /**
     * 
     * @return slideDefinitionID Slide Definition ID
     */
    public long getSlideDefinitionID() {
        return this.slideDefinitionID;
    }

    /**
     * 
     * @return childrenSlides List of children slides
     *     
     */
    public List<Slide> getChildrenSlides() {
        return this.childrenSlides;
    }

    /**
     * 
     * @param value children slides to set
     *     
     */
    public void setChildrenSlides(List<Slide> value) {
        this.childrenSlides = value;
    }
    
    /**
     * Adds new child slide to childrens list
     * 
     * @param child 
     */
    public void addChild(Slide child) {
        if(this.childrenSlides == null) {
                this.childrenSlides = new ArrayList<Slide>();
        }
        
        this.childrenSlides.add(child);
    }

    /**
     * Handy function to check existence of children
     * 
     * @return boolean
     */
    public boolean hasChildrenSlides() {
        return !(this.childrenSlides == null || this.childrenSlides.isEmpty());
    }
    
    /**
     * 
     * @return features
     *     
     */
    public List<Feature> getFeatures() {
        return this.features;
    }

    /**
     * Handy function to check existence of features
     * 
     * @return boolean
     */
    public boolean hasFeatures() {
        return !(this.features == null || this.features.isEmpty());
    }
    
    /**
     * 
     * @param value
     *     
     */
    public void setFeatures(List<Feature> value) {
        this.features = value;
    }

    /**
     * 
     * @return freeformContent
     *     
     */
    public FreeformContent getFreeformContent() {
        return this.freeformContent;
    }

    /**
     * 
     * @param value
     *     
     */
    public void setFreeformContent(FreeformContent value) {
        this.freeformContent = value;
    }

        /**
         * @return the isBorrowed
         */
//      public boolean isBorrowed() {
//              return this.borrowedCategoryID != 0L;
//      }

        /**
         * @param borrowedCategoryID the borrowedCategoryID to set
         */
//      public void setBorrowedCategoryID(long borrowedCategoryID) {
//              this.borrowedCategoryID = borrowedCategoryID;
//      }

        /**
         * @return the borrowedCategoryID
         */
//      public long getBorrowedCategoryID() {
//              return borrowedCategoryID;
//      }

        /* (non-Javadoc)
         * @see java.lang.Object#equals(java.lang.Object)
         */
        @Override
        public boolean equals(Object obj) {
                return this.getSlideDefinitionID() == 
                        ((Slide)obj).getSlideDefinitionID();
        }

        /* (non-Javadoc)
         * @see java.lang.Object#toString()
         */
        @Override
        public String toString() {
                return "Slide [borrowedCategoryID=" //+ borrowedCategoryID
                                + ", childrenSlides=" + childrenSlides + ", features="
                                + features + ", freeformContent=" + freeformContent
                                + ", slideDefinitionID=" + slideDefinitionID + "]";
        }

}