Subversion Repositories SmartDukaan

Rev

Rev 21 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

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

import java.io.Serializable;

/**
 * @author naveen
 * 
 * Singleton
 */
public class SequenceGenerator implements Serializable {
        private static final SequenceGenerator sequenceGenerator = new SequenceGenerator();

        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        public static final int UNIT = 0;

        /**
         * 
         * @return      SequenceGenerator       single instance of SequenceGenerator
         */
        public static final SequenceGenerator getInstance() {
                return sequenceGenerator;
        }
        
        /**
         * 
         */
        private long[] currentCounts;

        /**
         * A private Constructor prevents any other class from instantiating
         */
        private SequenceGenerator() {
                this.currentCounts = new long[1];
                
                // Set initial values
                this.currentCounts[UNIT] = 1010000;
        }
        
        /**
         * 
         * @param index
         * @return currentCount
         */
        public long getNextSequence(int index) {
                return this.currentCounts[index]++;
        }
        
}