package de.renew.net;


/**
 * This ID factory creates unique IDs by counting from
 * 0 or a given value upwards. Using the start value,
 * it is applicable for database backing.
 * The factory will generate IDs that are unique within
 * a JVM.
 */
public class TrivialIDFactory implements IDFactory {
    private long _count;

    /**
     * Constructs a {@code TrivialIDFactory} that creates IDs by starting to count at 0.
     */
    public TrivialIDFactory() {
        _count = 0;
    }

    /**
     * Constructs a {@code TrivialIDFactory} that creates IDs by starting to count at a given value.
     *
     * @param startCount the value at which to start counting to generate IDs
     */
    public TrivialIDFactory(int startCount) {
        _count = startCount;
    }

    /**
    * Create another ID. Each call will return the string
    * representation of a number that advances by one on
    * each call.
    *
    * @return a unique string
    */
    @Override
    public String createID() {
        return String.valueOf(_count++);
    }
}