Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 shop2020 1
/**
2
 * 
3
 */
4
package in.shop2020.metamodel.util;
5
 
6
import java.io.Serializable;
7
 
8
/**
9
 * @author naveen
10
 * 
11
 * Singleton
12
 */
13
public class SequenceGenerator implements Serializable {
14
	private static final SequenceGenerator sequenceGenerator = new SequenceGenerator();
15
 
16
	/**
17
	 * 
18
	 */
19
	private static final long serialVersionUID = 1L;
20
	public static final int UNIT = 0;
21
 
22
	/**
23
	 * 
24
	 * @return 	SequenceGenerator 	single instance of SequenceGenerator
25
	 */
26
	public static final SequenceGenerator getInstance() {
27
		return sequenceGenerator;
28
	}
29
 
30
	/**
31
	 * 
32
	 */
33
	private long[] currentCounts;
34
 
35
	/**
36
	 * A private Constructor prevents any other class from instantiating
37
	 */
38
	private SequenceGenerator() {
39
		this.currentCounts = new long[1];
40
 
41
		// Set initial values
42
		this.currentCounts[UNIT] = 1010000;
43
	}
44
 
45
	/**
46
	 * 
47
	 * @param index
48
	 * @return currentCount
49
	 */
50
	public long getNextSequence(int index) {
51
		return this.currentCounts[index]++;
52
	}
53
 
54
}