Class SimpleTraceGenerator

  • All Implemented Interfaces:
    TraceNumberGenerator

    public class SimpleTraceGenerator
    extends java.lang.Object
    implements TraceNumberGenerator
    Simple implementation of a TraceNumberGenerator with an internal number that is increased in memory but is not stored anywhere.
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleTraceGenerator​(int initialValue)
      Creates a new instance that will use the specified initial value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getLastTrace()
      Returns the last number that was generated.
      int nextTrace()
      Returns the next number in the sequence.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SimpleTraceGenerator

        public SimpleTraceGenerator​(int initialValue)
        Creates a new instance that will use the specified initial value. This means the first nextTrace() call will return this number.
        Parameters:
        initialValue - a number between 1 and 999999.
        Throws:
        java.lang.IllegalArgumentException - if the number is less than 1 or greater than 999999.
    • Method Detail

      • nextTrace

        public int nextTrace()
        Returns the next number in the sequence. This method is synchronized, because the counter is incremented in memory only.
        Specified by:
        nextTrace in interface TraceNumberGenerator